FIX: Long Field Names May Cause GP Fault in VB.EXE

ID: Q113281

3.00 WINDOWS kbinterop kbprg kbbuglist

The information in this article applies to:

- Microsoft Visual Basic programming system for Windows, version 3.0

SYMPTOMS

Visual Basic may generate a general protection (GP) fault when attempting to compile or run from within the environment or in VB.EXE at 002F:????. The offset may vary. 002F:08AF, 002F:0293, 002F:0860 were reproduced in testing with the code in this article.

CAUSE

When Visual Basic attempts to parse the code for compilation as it is creating an EXE or attempting to run from within the Visual Basic environment, a GP fault occurs if the field name accessed by the Table object is longer than 41 characters and there is a space in the name.

If you do not have a space in the name, Visual Basic will give you an "Identifier too long" error message.

WORKAROUND

Replace the problem line of code to avoid the problem. For example, using the code listed in the "Steps to Reproduce Problem" below:

Replace: TB![AFieldNameThisLong CausesTheUAEPromlemInVBEXE] = 6

         ' Problem line of code

with:    X$ = "AFieldNameThisLong CausesTheUAEPromlemInVBEXE"
         TB.Fields(X$).value = 6

or: TB.Fields("AFieldNameThisLong CausesTheUAEPromlemInVBEXE").Value = 6

STATUS

Microsoft has confirmed this to be a bug in the products listed at the beginning of this article. 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

To re-create the problem, you must first create the sample database with the long field name in it. This can be done using the Data Manager (DATAMGR.EXE).

1. Run DATAMGR.EXE. The file should be in your \VB directory.

2. Choose New Database from the File Menu. Then choose the Microsoft Access

   1.1 Database option, and enter the name TESTDB.MDB.

3. You will now see the Tables dialog box. From here choose the New command
   button, and enter the name Table1.

4. From the Fields dialog box, choose the New command button to add a new
   field. Give the field this name:

       AFieldNameThisLong CausesTheUAEProblemInVBEXE

5. Make the field type an integer, and then exit the Data Manager.
   TESTDB.MDB is now created.

Enter the following code from the Visual Basic environment. It is not necessary that the database TESTDB.MDB already exist. The GP fault occurs while the code is being parsed and before it can be run.

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

2. Add a command button (Command1) to the form.

3. Add the following code to the Command1_Click event:

   Sub Command1_Click ()
      Dim DB As Database
      Dim TB As Table
      Set DB = OpenDatabase("TestDB.MDB")
      Set TB = DB.OpenTable("Table1")
      TB.AddNew
      ' Error occurs on the following line
      TB![AFieldNameThisLong CausesTheUAEPromlemInVBEXE] = 6
      TB.Close
      DB.Close
   End Sub

4. Choose Make EXE or attempt to run the code from the environment. A GP
   fault is the result.

Additional reference words: buglist3.00 GPF gp-fault fixlist4.00 KBCategory: kbinterop kbprg kbbuglist KBSubcategory: APrgDataIISAM
Keywords          : kbDatabase kbIISAM kbbuglist
Version           : 3.00
Platform          : WINDOWS
Solution Type     : kbfix

Last Reviewed: November 2, 1997