Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compile Error: Expected: = 1

Status
Not open for further replies.

spizotfl

MIS
Aug 17, 2005
345
US
Hi, i am playing around with some functions related to an earlier post about domain functions. anywho: i wrote the following thing as a sorta DLookup replacement figuring that i might learn something simple along the way.
i put:
MyLookUp("Last","tblDemographics","SSN = 'XXXXXXXX'")
in the Immediate window to test and got nothing, but the "Compile Error: Expected: =" message. i commented out everything except for a debug.print("1") line, and still got this error. any thoughts??

Code:
Function MyLookUp(fldName As String, tblName As String, condition As String) As String

Dim strQuery As String
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset

strQuery = "Select " & fldName & " From " & tblName & " Where " & condition
Debug.Print (strQuery)
With rst
    Set .ActiveConnection = CurrentProject.Connection
    .CursorType = adOpenKeyset
    .Open strQuery
End With
Debug.Print ("1") '(rst.Fields(fldName).Value)
MyLookUp = rst.Fields(fldName).Value

rst.Close
Set rst = Nothing

End Function
 
In the immediate window:
[!]? [/!]MyLookUp("Last","tblDemographics","SSN = 'XXXXXXXX'")

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top