Won't work with Alpha/Numeric value

H

Hookfoot

Does anyone know why this won't work with alpha/numeric values? It will work
with integers.

Private Sub txtID_BeforeUpdate(Cancel as Integer)
If Not IsNull(DLookUp("[ID]", "
", "[ID] = " & Me!txtID)) Then
Cancel = True
MsgBox "This ID already loaded", vbOKOnly
End If
End Sub

Any help is appreciated.

Hookfoot
 
K

Ken Snell [MVP]

You must delimit text strings with ' characters:

If Not IsNull(DLookUp("[ID]", "
", "[ID] = '" & Me!txtID & "'")) Then
 

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