Data type mismatch

P

Praveen Manne

Hi,

I have two tables ..
1.tblPhys (fields are SSN, Sal)
2.tblTransTemp (fields are SSN, Sum,....)

the SSN field type is Text (not number)

I designed a form(frmTransA) which is connected to the tblTransTemp.
I have a combo box on the form frmTransA, thru which I can select the SSN
from the tblPhys
I have a text box, named Sal

When I select the SSN the Sal text box should populate the corresponding
value of that SSN .
This is the statement I Wrote for the After Update event of SSN Combo :
Me!Sal = DLookup("[Sal]", "tblPhys", "[SSN]=" & Forms!frmTransA!SSN)

But When I select the SSN .." Data Type MisMatch in Criteria Expression "
error is popping up . Do any one of you know how can I get rid of this
error?

Please Help

Thanks
Praveen
 
D

Douglas J. Steele

Since SSN is text, you need to enclose the value in quotes:

Me!Sal = DLookup("[Sal]", "tblPhys", "[SSN]=" & Chr$(34) &
Forms!frmTransA!SSN & Chr$(34))

or

Me!Sal = DLookup("[Sal]", "tblPhys", "[SSN]='" & Forms!frmTransA!SSN & "'")

Exagerated for clarity, that second one is:

Me!Sal = DLookup("[Sal]", "tblPhys", "[SSN]=' " & Forms!frmTransA!SSN & " '
" )
 
J

John Vinson

the SSN field type is Text (not number)

Therefore there are syntactically required quotemarks when you search
for it:

Me!Sal = DLookup("[Sal]", "tblPhys",
"[SSN]='" & Forms!frmTransA!SSN & "'")
 

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