dlookup error

lipin

Registered User.
Local time
Today, 02:23
Joined
May 21, 2002
Messages
149
I have the following on the AfterUpdate property of a control on a form:
If DLookup("[Employee Number]", "tblEmployee", "[4SSN] = " & Me![txtpass]) Then.....

After I enter the password on the form I keep getting the error "data type mismatch in criteria expression"

4SSN is a text field in the table 'tblEmployee' (I made it text so I didn't lose my leading zeroes)

and txtpass is an unbound textbox on the form.

Can someone please help??
 
You were treating [4SSN] as a numerical value in the expression.

Code:
If DLookup("[Employee Number]", "tblEmployee", "[4SSN] = '" & Me![txtpass] & "'") Then

You need to remember that for Access to recognise it as a string you will have to put the apostrophe ( ' ) character on either side of the string in question.

As an aside, just in case you don't know, for dates, rather than use an apostrophe, the hash symbol is used.
 
Bit of light reading here. I refer to it when things get confusing

Dave
 

Attachments

Users who are viewing this thread

Back
Top Bottom