Thanks again for spending the time with this. Well I did all your
suggestions and now the error changed to "Data type mismatch in
criteria expression". If I take out the second criteria and execute it
only with ID it works perfectly. This is my revised code as follows:
RS.Open "SELECT * FROM Attendance WHERE ID = '" &
Form_Attendance.CmbID.Value & "' AND [DT] = '" &
Form_Attendance.TxtDate.Value & "'", , adOpenDynamic, adLockOptimistic
You'll need to use # delimiter for a date value, and explicitly format the
date to US format. Try this:
RS.Open "SELECT * FROM Attendance WHERE ID = '" &
Form_Attendance.CmbID.Value & "' AND [DT] = #" &
Format(Form_Attendance.TxtDate.Value, "\#mm\/dd\/yyyy\#"), , adOpenDynamic,
adLockOptimistic

Signature
Ken Snell
<MS ACCESS MVP>
https://mvp.support.microsoft.com/profile/Kenneth.Snell
www.cadellsoftware.org
> Thanks again for spending the time with this. Well I did all your
> suggestions and now the error changed to "Data type mismatch in
[quoted text clipped - 4 lines]
> Form_Attendance.CmbID.Value & "' AND [DT] = '" &
> Form_Attendance.TxtDate.Value & "'", , adOpenDynamic, adLockOptimistic
Ken Snell (MVP) - 31 Mar 2007 20:25 GMT
Sorry - left in an extra # character -- corrected code line:
RS.Open "SELECT * FROM Attendance WHERE ID = '" &
Form_Attendance.CmbID.Value & "' AND [DT] = " &
Format(Form_Attendance.TxtDate.Value, "\#mm\/dd\/yyyy\#"), , adOpenDynamic,
adLockOptimistic
Also, if ID field is numeric, remove the ' characters that you're using as
delimiters:
RS.Open "SELECT * FROM Attendance WHERE ID = " &
Form_Attendance.CmbID.Value & " AND [DT] = " &
Format(Form_Attendance.TxtDate.Value, "\#mm\/dd\/yyyy\#"), , adOpenDynamic,
adLockOptimistic

Signature
Ken Snell
<MS ACCESS MVP>
https://mvp.support.microsoft.com/profile/Kenneth.Snell
www.cadellsoftware.org
> You'll need to use # delimiter for a date value, and explicitly format the
> date to US format. Try this:
[quoted text clipped - 12 lines]
>> Form_Attendance.CmbID.Value & "' AND [DT] = '" &
>> Form_Attendance.TxtDate.Value & "'", , adOpenDynamic, adLockOptimistic
LLazuta@gmail.com - 31 Mar 2007 20:29 GMT
Well I tried that code and now a new error showed up: "Syntax error
(missing operator) in Query expression 'ID = 'A12345' and [DT] =
##01/03/2007#'.
LLazuta@gmail.com - 31 Mar 2007 20:36 GMT
On Apr 1, 2:29 am, LLaz...@gmail.com wrote:
> Well I tried that code and now a new error showed up: "Syntax error
> (missing operator) in Query expression 'ID = 'A12345' and [DT] =
> ##01/03/2007#'.
Ops i didn't see your post. That last part did the trick, thanks a
million. :)