Microsoft KB Archive/113281

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

PSS ID Number: 113281

Article Last Modified on 1/8/2003

-

The information in this article applies to:


 * Microsoft Visual Basic Standard Edition for Windows 3.0

-



This article was previously published under Q113281



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.



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

 Run DATAMGR.EXE. The file should be in your \VB directory. Choose New Database from the File Menu. Then choose the Microsoft Access 1.1 Database option, and enter the name TESTDB.MDB. You will now see the Tables dialog box. From here choose the New command button, and enter the name Table1.  From the Fields dialog box, choose the New command button to add a new field. Give the field this name: AFieldNameThisLong CausesTheUAEProblemInVBEXE  Make the field type an integer, and then exit the Data Manager. TESTDB.MDB is now created.</li></ol>

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.

<ol> Start a new project in Visual Basic. Form1 is created by default.</li> Add a command button (Command1) to the form.</li>  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 </li> Choose Make EXE or attempt to run the code from the environment. A GP fault is the result.</li></ol>

Additional query words: buglist3.00 GPF gp-fault fixlist4.00

Keywords: kbbug kbIISAM KB113281

Technology: kbAudDeveloper kbVB300 kbVB300Search kbVBSearch

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© 2004 Microsoft Corporation. All rights reserved.