ACC2000: "Expected Function or Variable" Error Message (210134)
The information in this article applies to:
This article was previously published under Q210134 Moderate: Requires basic macro, coding, and interoperability skills.
This article applies only to a Microsoft Access database (.mdb).
SYMPTOMS
When you run or compile a procedure in a Microsoft Access database that
references a field that has the same name as a data access method of a
Recordset object, you may receive one of the following error messages:
Expected Function or variable
Argument not optional
Type Mismatch
CAUSE
You used the dot (.) syntax when you referenced a field that has the same name as a data access method of a Recordset object. For example, you may have a field called "Close" that is preceded by a dot, as follows:
Function Test()
Dim db As DAO.DATABASE, tb As DAO.Recordset, x As Variant
Set db = CurrentDb
Set tb = db.OpenRecordset("Table1")
x = x + tb.[Close]
End Function
RESOLUTIONNOTE: The sample code in this article uses Microsoft Data Access Objects. For this code to run properly, you must reference the Microsoft DAO 3.6 Object Library. To do so, click References on the Tools menu in the Visual Basic Editor, and make sure that the Microsoft DAO 3.6 Object Library check box is selected.
Modify the procedure to use the exclamation point (!) syntax in the
reference, for example:
Function Test()
Dim db As DAO.DATABASE, tb As DAO.Recordset, x As Variant
Set db = CurrentDb
Set tb = db.OpenRecordset("Table1")
x = x + tb![Close]
End Function
REFERENCESFor more information about naming conventions, in the Visual Basic Editor, click Microsoft Visual Basic Help on the Help menu, type naming conventions in the Office Assistant or the Answer Wizard, and then click Search to view the topic.
Modification Type: | Major | Last Reviewed: | 6/24/2004 |
---|
Keywords: | kberrmsg kbprb kbprogramming KB210134 |
---|
|