Solved How to set SQL Query for Text type field

rehanemis

Registered User.
Local time
Today, 17:10
Joined
Apr 7, 2014
Messages
195
Hello,
I have a statement written and getting problem in working when I changed the Field "EmpID" from number to Text.
Code:
strSql = "SELECT *, Format(Date(),'yyyy')-Format([DoB],'yyyy') AS Age FROM tblRecallSheetStatus WHERE EmpID=" & emp_no & " ;"
Set qdf = CurrentDb.QueryDefs("qrySearchRecordForReport")
qdf.SQL = strSql

Can anyone suggest the solution?
 
Try

strSql = "SELECT *, Format(Date(),'yyyy')-Format([DoB],'yyyy') AS Age FROM tblRecallSheetStatus WHERE EmpID='" & emp_no & "';"
 
Worked Perfectly!
Can you assist bit more as you can see in snapshot.
Capture.JPG
 
I don't use macros, but try adding a single quote right before the last double quote, and then this at the end:

& "'"
 

Users who are viewing this thread

Back
Top Bottom