ID: Q113332
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
It is possible to receive an "Illegal Function Call" error message in response to an AddNew method. This article demonstrates how this error can occur and how to work around it.
The cause of this problem has not yet been determined. We're researching it.
There are two ways to work around this problem. The first method is to move to the last record before adding the record. The following code demonstrates this work around:
Form1.AutoRedraw = True
Data1.DatabaseName = "DB.MDB"
Data1.RecordSource = "SELECT * FROM Table1 WHERE Field1 = 'Record1'"
Data1.Refresh
Data1.Recordset.MoveLast
Print "ReadOnly "; Data1.ReadOnly
Print "Options "; Data1.Options
Print "Updatable "; Data1.Recordset.Updatable
Data1.Recordset.AddNew
The other method is to delete the index. In the previous example, you would
delete Index1.
Microsoft has confirmed this to be a bug in Microsoft Visual Basic version 3.0 for Windows. This problem has been corrected in Visual Basic version 4.0.
A problem with the Microsoft Access database engine can cause an "Illegal Function Call" error when adding a record to a database. This error should not occur. This problem is not related to the data control and can also occur when using methods from the Professional Edition of Visual Basic version 3.0.
1. Use the Data Manager to create a database with these characteristics:
DATABASE: DB.MDB
TABLES: Table1
FIELDS: Field1 in Table1
INDEXES: Index1 on Field1 not Unique and not Primary
2. Add two records to Table1 with values of "Record1" and "Record2" for
Field1.
3. Start a new project in Visual Basic. Form1 is created by default.
4. Add a data control (Date1) and a command button (Command1) to the form.
5. Add the following code to the command button's click event:
Sub Command1_Click ()
Form1.AutoRedraw = True
Data1.DatabaseName = "DB.MDB"
Data1.RecordSource = "SELECT * FROM Table1 WHERE Field1 = 'Record1'"
Data1.Refresh
Print "ReadOnly "; Data1.ReadOnly
Print "Options "; Data1.Options
Print "Updatable "; Data1.Recordset.Updatable
Data1.Recordset.AddNew
End Sub
6. Run the code and click the Command1 button. You should receive the
"Illegal function call" error on the on the Addnew line.
Additional reference words: buglist3.00 3.00 buglist3.00 fixlist4.00
KBCategory: kbprg kbbuglist
KBSubcategory: APrgDataAcc
Keywords : APrgDataAcc kbbuglist
Version : 3.00
Platform : WINDOWS
Solution Type : kbfix
Last Reviewed: November 1, 1997