dlookup type mismatch?

G

Guest

Hi all,
I have an Access 97 front end which has just been linked to back end tables
in SQL Server 2000.
When trying to use the following code behind a text box before_update event,
I get a runtime error 62506, stating that there is a data type mismatch in
the criteria expression.

DLookup("[EmpName]", "tblEmployees", "[EmpPass] = " & Me!txtEmployee)

The column properties in the SQL Server table are varchar 15. This form ran
perfectly with the table linked to an Access table before hand.
Can anyone please explain what I need to do?
Also, what other things should I be aware of now that I have an SQL backend?

Thanks for your help,
Dave
 
D

Douglas J. Steele

Is EmpPass varchar 15? Then you must enclose the value you're using in
quotes:

DLookup("[EmpName]", "tblEmployees", "[EmpPass] = '" & Me!txtEmployee & "'")

where, exagerated for clarity, that's

DLookup("[EmpName]", "tblEmployees", "[EmpPass] = ' " & Me!txtEmployee & " '
")
 
G

Guest

Thanks Douglas.
That worked.

Dave

Douglas J. Steele said:
Is EmpPass varchar 15? Then you must enclose the value you're using in
quotes:

DLookup("[EmpName]", "tblEmployees", "[EmpPass] = '" & Me!txtEmployee & "'")

where, exagerated for clarity, that's

DLookup("[EmpName]", "tblEmployees", "[EmpPass] = ' " & Me!txtEmployee & " '
")


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Dave said:
Hi all,
I have an Access 97 front end which has just been linked to back end
tables
in SQL Server 2000.
When trying to use the following code behind a text box before_update
event,
I get a runtime error 62506, stating that there is a data type mismatch in
the criteria expression.

DLookup("[EmpName]", "tblEmployees", "[EmpPass] = " & Me!txtEmployee)

The column properties in the SQL Server table are varchar 15. This form
ran
perfectly with the table linked to an Access table before hand.
Can anyone please explain what I need to do?
Also, what other things should I be aware of now that I have an SQL
backend?

Thanks for your help,
Dave
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top