ACC2: GPF Using List Box Fill Function with Requery Method

ID: Q117615


The information in this article applies to:


SYMPTOMS

When you fill a list box using an Access Basic function, and the function returns a static variable upon receiving the close code (8), and you then use the Requery method to requery the list box, you receive a general protection (GP) fault.


CAUSE

The temporary string created by the list box fill function is not freed, and conflicts with another variable used internally by Microsoft Access.


RESOLUTION

Use one of the following techniques to work around this problem:


STATUS

Microsoft has confirmed this to be a problem in Microsoft Access version 2.0. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.


MORE INFORMATION

Steps to Reproduce Problem

WARNING: Following these steps will result in a GP fault. Save and then close any open work on your computer before following these steps.

NOTE: In the following example, an underscore (_) at the end of a line is used as a line-continuation character. Remove the underscore from the end of the line when re-creating this example.
  1. Start Microsoft Access and open the sample database NWIND.MDB.


  2. Create a new, blank form.


  3. Click the Code button on the toolbar, or choose Code from the View menu, and then enter the following code in the form module:
    
          Option Compare Database   'Use database order for string _
                                     comparisons. 




      Dim iTotTables As Integer
      Dim My_CurrDB As Database
      Dim TableList2() As String
      Dim iTotFlds As Integer
      Dim FieldList() As wlib_FldInfo

      Function FillTables (fld As Control, handle As Long, lRow As _
      Long, lCol As Long, iMsg As Integer) As Variant

         Static returnval As Variant
         ' If you change the above line to the following the error
         ' will not occur:
         ' Dim returnval As Variant

         Select Case iMsg
            Case LB_INITIALIZE
               returnval = -1&
            Case LB_OPEN
               returnval = Timer
            Case LB_GETROWCOUNT
               returnval = iTotTables
            Case LB_GETCOLUMNCOUNT
               returnval = 1
            Case LB_GETCOLUMNWIDTH
               returnval = -1&
            Case LB_GETVALUE
               returnval = TableList2(lRow + 1)
            Case LB_GETFORMAT
            Case LB_CLOSE
            Case LB_END
          End Select
          FillTables = returnval
       End Function 

  1. Add the following command button and list box to the form:
    
          Command button:
             Name: Button0
             Caption: Requery Table List
    
          List box:
             Name: Field1
             RowSourceType: FillTables 


  2. Set the command button's OnClick property to the following event procedure:
    
          Sub Button0_Click ()
             Set My_CurrDB = DBEngine.Workspaces(0).Databases(0)
             iTotTables = wlib_GetObjList(My_CurrDB, A_TABLE, TableList2(),_
              False, &HFFFFFFFF)
             Me!Field1.Requery
          End Sub 


  3. View the form in Form view.


  4. Click the Requery Table List button 8 or more times. You will receive the error message:
    General Protection Fault in MSABC200.DLL at 000B:07E1



REFERENCES

For more information about using Access Basic code to fill a list box, search for "filling list boxes/combo boxes" then "Filling a List Box or Combo Box Using an Access Basic Function" using the Microsoft Access Help menu.

Additional query words: programming gpf


Keywords          : kberrmsg kbprg 
Version           : 2.0
Platform          : WINDOWS 
Issue type        : kbbug 

Last Reviewed: April 5, 1999