FIX: Field Name Same as Reserved Word Can Cause GP Fault

ID: Q113687

3.00 WINDOWS kbprg kbbuglist

The information in this article applies to:

- Standard and Professional Editions of Microsoft Visual Basic for

  Windows, version 3.0

SYMPTOMS

It is possible to receive a general protection (GP) fault in VB.EXE at the address 0025:3182 when using the data access features of Visual Basic. You may also notice corruption in your source code if the source is saved in the binary format and reloaded. The problem may not occur all the time.

CAUSE

This problem stems from using field names that are reserved words in Visual Basic. The problem occurs when using the following syntax to reference the field:

   Recordset![Reserved]

where "Recordset" is a table, dynaset, snapshot, or data control recordset, and "Reserved" is any Visual Basic reserved word.

RESOLUTION

To avoid the problem use the Fields collection to refer to the field. For example:

   Recordset.Fields("Reserved").Value
   Recordset("Reserved")

where "Recordset" is a table, dynaset, snapshot, or data control recordset, and "Reserved" is any Visual Basic reserved word.

STATUS

Microsoft has confirmed this to be a bug in Visual Basic version 3.0 for Windows. This problem has been corrected in Visual Basic version 4.0.

Steps to Reproduce Problem

1. Start a new project in Visual Basic. Form1 will be created by default.

2. Add the following code to the Form Load event:

   Sub Form_Load()
      Dim tb As Table
      tb![To] = 12
   End Sub

3. Run the program. You should get an error and the code will be changed to
   the following.

   Sub Form_Load()
      Dim tb As Table
      tb!To = 12
   End Sub

Additional reference words: buglist3.00 3.00 fixlist4.00 GPF KBCategory: kbprg kbbuglist KBSubcategory: APrgDataAcc
Keywords          : APrgDataAcc kbbuglist
Version           : 3.00
Platform          : WINDOWS
Solution Type     : kbfix

Last Reviewed: November 1, 1997