Form error

JoeAcess

Jones
Local time
Today, 04:33
Joined
Dec 9, 2008
Messages
25
Hello everybody

I made a form where i need to take a name by giving just the id. So i gave the Dlookup commnad but there is an error "data type mismatch in criteria expression". Can anybody please help





Code:
Private Sub Command97_Click()

Me.PtName = DLookup("Baby_Name", "tblFollow_up", "Study_ID='" & Forms!FrmPtAmount!ID & "'")

End Sub
 
Last edited:
Howzit

Try...

Code:
Me.PtName = DLookup("Baby_Name", "tblFollow_up", "Study_ID=" & Forms!FrmPtAmount!ID )

If this code is part of the form FrmPTAmount you can use

Code:
Me.PtName = DLookup("Baby_Name", "tblFollow_up", "Study_ID=" & me.ID )
 
hey thanks that worked

:)
 
Just so that you understand the actual problem

Code:
Me.PtName = DLookup("Baby_Name", "tblFollow_up", "Study_ID='" & Forms!FrmPtAmount!ID & "'")
is the correct syntax if Study_ID was defined as a Text field, while

Code:
Me.PtName = DLookup("Baby_Name", "tblFollow_up", "Study_ID=" & Forms!FrmPtAmount!ID )
is correct when Study_ID is defined as a Numeric datatype, which apparently is the case here.
 

Users who are viewing this thread

Back
Top Bottom