DLookup syntax problem (1 Viewer)

cronid

Registered User.
Local time
Today, 18:46
Joined
Dec 26, 2004
Messages
10
I am trying to implement DLookup for the following sql to a linked SQL Server table to verify that the currentuser is in my Traders table:

select tr_username from Traders where tr_username='edobbie'

When I enter the following DLookup command I get the error 'compile error expected ='

The offending line is:

DLookup("tr_username","Traders","[tr_username] = " &CurrentUser())

The Editor doesn't seem to see the = sign in my criteria. I've modified the syntax a number of ways to no avail.

Does anyone see the problem?
 

PeterF

Registered User.
Local time
Tomorrow, 00:46
Joined
Jun 6, 2006
Messages
295
First problem is that the function CurrentUser returns a String so the Dlookup function should look like this:

DLookup("tr_username","Traders","[tr_username] = '" & CurrentUser() & "'")

The compile error you get on the = sign is because you don't do anything with the result of the function. If you you use the result to set a variable or in a if statement the error is gone.
 

cronid

Registered User.
Local time
Today, 18:46
Joined
Dec 26, 2004
Messages
10
You're right. Thanks for taking the time.

Den
 

Users who are viewing this thread

Top Bottom