ACC1x: Error Messages When Concatenating Variables or ControlsID: Q96576
|
Moderate: Requires basic macro, coding, and interoperability skills.
When you are concatenating variables or controls in a function or
CreateDynaset method, you may receive one of the following error messages:
Can't bind name '<argument>'
-or-
Type Mismatch
-or-
1 parameter expected only 0 supplied
Call the function as follows: MyFunction ("Davolio")
Function MyFunction (DataToFind As String)
Dim MyDB As Database, myset As Dynaset
Set MyDB = CurrentDB()
Set myset = MyDB.CreateDynaset("Employees")
Myset.FindFirst "[Last Name]= " & DataToFind
End Function
MySet.FindFirst "[Last Name] = '" & DataToFind & "'"
Call the function as follows: MyFunction (3).
Function MyFunction (NumberToFind As integer)
Dim MyDB As Database, MySet As Dynaset
Set MyDB = CurrentDB()
Set MySet = MyDB.CreateDynaset("Employees")
MySet.FindFirst "[Employee ID] = '" & NumberToFind & "'"
MySet.FindFirst "[Employee ID] = " & NumberToFind
MySet.FindFirst "[Hire Date] = #" & DateToFind & "#"
MySet.FindFirst "[Employee ID] = " & NumericDataToFind
Function TestQP ()
Dim MyDB As Database, MySet As Dynaset
Set MyDB = CurrentDB()
Set MySet = MyDB.CreateDynaset("Query1")
Debug.Print MySet![First Name]; Tab(10); MySet![Last Name]
End Function
Function TestQP ()
Dim MyDB As Database, MySet As QueryDef, MyDyna As Dynaset
Set MyDB = CurrentDB()
Set MySet = MyDB.OpenQueryDef("Query1")
MySet![Enter a Name] = "Davolio"
Set MyDyna = MySet.CreateDynaset()
Debug.Print MyDyna![First Name]; Tab(10); MyDyna![Last Name]
MyDyna.Close
MySet.Close
End Function
Set MySet = MyDB.CreateDynaset("SELECT * FROM Employees WHERE _
[Employee ID] = " & Forms!Form1!Field0 & ";")
Additional query words: parameters
Keywords : kberrmsg kbprg PgmObj
Version : 1.0 1.1
Platform : WINDOWS
Issue type : kbinfo
Last Reviewed: March 20, 1999