ACC2: GPF Using List Box Fill Function with Requery Method

Last reviewed: June 8, 1997
Article ID: Q117615
The information in this article applies to:
  • Microsoft Access version 2.0

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:

  • Use a Requery action instead of the Requery method for requerying the list box.
  • Do not return a static string when your function exits through the close code (8). That is, dimension the variable to make it dynamic, rather than declaring it static.

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
    
    

  4. 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
    
    

  5. 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
    
    

  6. View the form in Form view.

  7. 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 : EvnGpf kberrmsg kbprg PgmOthr
Version : 2.0
Platform : WINDOWS
Hardware : X86
Issue type : kbbug
Resolution Type : kbworkaround


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: June 8, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.