Mismatch Error

G

Guest

When I try to look for a duplicate value in a record I keep getting the
following error....

Run-time error '3464'
Data type Mismatch in criteria expression

here is the code I am using when I get the error....

Dim varResult As Variant

varResult = DLookup("DrawingNum", "tbl_DrawingsAndData", _
"DrawingNum = " &
Me.DrawingNum)
If Not IsNull(varResult) Then
strMsg = "Drawing " & varResult & " Already Exists."
End If

Anyone know what is wrong???? If there is a better way to see if the data in
the text box on the data entry form is already in the table please let me
know.
 
D

Dan Artuso

Hi,
If your criteria is numerical, you do not need any delimiters.
It sounds like your DrawingNum is a string so you need to delimit with
quotes:

varResult = DLookup("DrawingNum", "tbl_DrawingsAndData", _
"DrawingNum = '" & Me.DrawingNum & "'")

If your criteria was a date then you'd need to delimit with #
 
G

Guest

Hey, that did get rid of the Mismatch error but it is still not seeing that
it is already in the table because now when I run the code Access error 3202
appears saying that there is a duplicate primary key, that is the whole point
of my code so I am not sure why it isn't picking it up. There has got to be
a way to check the table and display my own message. I am about to give up
I have tried everything, anyone know what the *&^% is going on here????????
 

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