Data type mismatch 3464

nigelh

Registered User.
Local time
Today, 20:26
Joined
Sep 27, 2001
Messages
27
I've seen a few posts when searching on this but none which solve my problem.

Private Sub Combo0_Change()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim emp Long
emp = Me!Combo0.Value
Set db = CurrentDb
Debug.Print emp
Set rs = db.OpenRecordset( _
"select daystaken from tblholstaken where [employee] = 'emp' ", dbOpenDynaset, dbReadOnly)
Debug.Print Me!Combo0.Value
Do While Not rs.EOF

Debug.Print rs.Fields("daystaken").Value

rs.MoveNext
Loop

End Sub

The Employee field in tblholstaken is type Long Integer.

Can anyone explain why I am getting the error on the SQL code.

The combo0 value is taken from the employee value in a query.

Thanks in advance.
 
You are placing a variable into a string expression so it ought to be:


for numerical variables:
...[employee]=" & emp & "...

for string variables:
...[employee]='" & emp & "'... {note the single quotes}

HTH
 
Thanks Harry.
 

Users who are viewing this thread

Back
Top Bottom