Link to home
Start Free TrialLog in
Avatar of fanguru1
fanguru1

asked on

Filtering Between dates with adodc

I am having problems with this code:
Adodc1.Recordset.Filter = "Date BETWEEN #" & dtestart & "# AND #" & dteend & "#"
I am getting an error:
Run-time error '3001':
Arguments are of the wrong type, or out of acceptable range, or are in conflict with one another.

Any help with this code would be greatly appreciated.

Thanks,
Jeff
ASKER CERTIFIED SOLUTION
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of fanguru1
fanguru1

ASKER

I changed my database and the related links to that field to OrderDate.
This is the code I now have
Adodc1.Recordset.Filter = "OrderDate BETWEEN #" & dtestart & "# AND #" & dteend & "#"
I still have the same error.

I found this code and it worked fine:
FYI:
.Filter = "[OrderDate] >= #" & dtestart & "# AND [OrderDate] <= #" & dteend & " #"
BTW, fanguru1 I would seroiusly suggest you get rid of ADODC and use ADO directly.

Leon
what's the data type of OrderDate? make sure it's a Date/Time data field? Also make sure the values of dtestart and dteend is valid to the field data type.
Run-time error '3001'
error discription (Arguments are of the wrong type)
You are trying to  apply date filteration to none date-type  field

as ryancys said check orderdate type

and if this code works
.Filter = "[OrderDate] >= #" & dtestart & "# AND [OrderDate] <= #" & dteend & " #"

between MUST work also

regards
For dtestart  and dteend, if this is based on your machines locale, then it may not be the same as the DB, e.g. dd/mm/yyyy.
Have you tried doing :

"#" & Format(dtestart,"dd/mm/yyyy HH:mm:ss") & "#"

Or the respective format ot the DB you are trying to filter.