Type Mismatch error

  • Thread starter al416 via AccessMonster.com
  • Start date
A

al416 via AccessMonster.com

Any idea why I am getting a "Data Type mismatch on criteria expression" error
on the second line?

MaxCAR = DMax("[CARNumber]", "tblCARs")
LastAuditNumber = DLookup("[AuditNumber]", "tblCARs", "[CARNumber] = '" &
MaxCAR & "'")

Both Fields are dimensioned as Integers
CARNumber is and Auto number field
 
R

RonaldoOneNil

Because you have delimited it with single quotes which represents a string.
When the value is numeric, you do not need to set quotes around it

LastAuditNumber = DLookup("[AuditNumber]", "tblCARs", "[CARNumber] = " &
MaxCAR)
 
J

J_Goddard via AccessMonster.com

Hi -

It's because you have enclosed MaxCAR in single quotes, so Access interprets
it as a string. Trying to compare a number to a string generates the error.
Remove the quotes areound MaxCAR and it should work fine.

John

Any idea why I am getting a "Data Type mismatch on criteria expression" error
on the second line?

MaxCAR = DMax("[CARNumber]", "tblCARs")
LastAuditNumber = DLookup("[AuditNumber]", "tblCARs", "[CARNumber] = '" &
MaxCAR & "'")

Both Fields are dimensioned as Integers
CARNumber is and Auto number field
 

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