CharleyD
asked on
Dlookup data Mismatch
When I run the follwing code I get a run time error '62506' , Data type mismatch in criteria expression.
code
Option Compare Database
Option Explicit
Private Sub CUID_BeforeUpdate(Cancel As Integer)
Dim varX As String, resp As Integer
varX = DLookup("[group]", "tblCuidold", "[cuid] = " & Forms!tblCuidAdd!CUID)
If (varX = "") Then GoTo lastline
resp = MsgBox("CUID is already in use", vbOKOnly, "CUID Check")
lastline:
End Sub
The field CUID is Exactly the same in both database, Length of 5 type of text. I copied the structure from one to the other.
When I go to debug after the failure ithe Dlookuop line is highlight.
code
Option Compare Database
Option Explicit
Private Sub CUID_BeforeUpdate(Cancel As Integer)
Dim varX As String, resp As Integer
varX = DLookup("[group]", "tblCuidold", "[cuid] = " & Forms!tblCuidAdd!CUID)
If (varX = "") Then GoTo lastline
resp = MsgBox("CUID is already in use", vbOKOnly, "CUID Check")
lastline:
End Sub
The field CUID is Exactly the same in both database, Length of 5 type of text. I copied the structure from one to the other.
When I go to debug after the failure ithe Dlookuop line is highlight.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
DLookup("[group]", "tblCuidold", "[cuid] = '" & Forms!tblCuidAdd!CUID) & "'"
DLookup("[group]", "tblCuidold", "[cuid] =' " & Forms!tblCuidAdd!CUID & " ' ")