DLookup Question

D

Don

I have a table called tblCUSTOMER with 3 fields: CUST_NO, CUSTOMER, ROUTE_NO.
I have a form with 3 unbound text boxes: txtCUST_NO, txtCUSTOMER,
txtROUTE_NO. Using the afterupdate event property, I want to populate
txtCUSTOMER and txtROUTE_NO when I key in the customer number in the
txtCUST_NO field.

When I enter a customer number in the text box, I get the following error:

Data type mismatch in criteria expression. (Error 3464)
The criteria expression in a Find method is attempting to compare a field
with a value whose data type does not match the field’s data type.

The DLookup was written as such - can anyone help me?

Private Sub txtCUST_NO_AfterUpdate()

Me.txtCUSTOMER = DLookup("[CUSTOMER]", "tblCUSTOMER", "[CUST_NO] =" _
& Forms![frmERROR_HEADER]!txtCUST_NO)

End Sub
 
P

Paul B.

Don,

try this....


Me.txtCUSTOMER = DLookup("CUSTOMER", "tblCUSTOMER", "CUST_NO =" _
& Forms!frmERROR_HEADER!txtCUST_NO)


I have had similar problems using DLookup and found little help with the
actual format which is dependant on the types of data you are looking up.


If this doesn't work, refer to this webpage...It has helped me....

http://members.iinet.net.au/~allenbrowne/casu-07.html

Cheers
 
F

fredg

I have a table called tblCUSTOMER with 3 fields: CUST_NO, CUSTOMER, ROUTE_NO.
I have a form with 3 unbound text boxes: txtCUST_NO, txtCUSTOMER,
txtROUTE_NO. Using the afterupdate event property, I want to populate
txtCUSTOMER and txtROUTE_NO when I key in the customer number in the
txtCUST_NO field.

When I enter a customer number in the text box, I get the following error:

Data type mismatch in criteria expression. (Error 3464)
The criteria expression in a Find method is attempting to compare a field
with a value whose data type does not match the field¢s data type.

The DLookup was written as such - can anyone help me?

Private Sub txtCUST_NO_AfterUpdate()

Me.txtCUSTOMER = DLookup("[CUSTOMER]", "tblCUSTOMER", "[CUST_NO] =" _
& Forms![frmERROR_HEADER]!txtCUST_NO)

End Sub

Assuming Access isn't lying to you, I would have to venture that
[Cust_No] is not a Number datatype, as your syntax would indicate, but
text.

Try it this way:

Me!txtCUSTOMER = DLookup("[CUSTOMER]", "tblCUSTOMER", "[CUST_NO] = '"
& [Forms]![frmERROR_HEADER]![txtCUST_NO] & "'")

If this code is written on the "frmError_Header" form, use the Me
keyword to make it a bit more compact:

Me!txtCUSTOMER = DLookup("[CUSTOMER]", "tblCUSTOMER", "[CUST_NO] = '"
& Me![txtCUST_NO] & "'")
 

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

Top