Having trouble in ADO setting a recordset

illy2k

Registered User.
Local time
Today, 00:24
Joined
Apr 21, 2003
Messages
51
I am trying to create a recordset that takes a date which is on the current form, and uses that to set the recordset to every record which has a date previous to the one entered on that form. Using this code in the on click event I keep getting a data type mismatch error.

PurgeRst.Open "SELECT * FROM [Item File] WHERE [Date] <= """ & Me!DeleteStartDate & """", _
CurrentProject.Connection, adOpenStatic, adLockOptimistic

Any Ideas on where this code is going wrong?

Thanks
 
illy2k said:
"SELECT * FROM [Item File] WHERE [Date] <= """ & Me!DeleteStartDate & """"

Three observations:

  • Date is a reserved word and should not be used as a field name;
  • Use Me. rather than Me!
  • You have the wrong delimiters because the field is a date and not a string;

"SELECT * FROM [Item File] WHERE [Date] <= #" & Me.DeleteStartDate & "#;"
 

Users who are viewing this thread

Back
Top Bottom