Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with dates...

Status
Not open for further replies.

lulo

Programmer
Jan 24, 2001
51
0
0
US
Filter not working.

(Run time error '3001'
'Argument are of the wrong type, are out of acceptable range, or are in conflict with one another.')


This is my code (access2000 db)
Field in table is of type "Date/time"

rs.Filter ="TrainingDate BETWEEN #" & txtTrainFrom & "# AND #" & txtTrainTo & "#"

Does anyone has any suggestions?

Thank you for your time.

Lulo
 
Try this

rs.Filter ="TrainingDate BETWEEN #" & CDate(txtTrainFrom) & "# AND #" & CDate9txtTrainTo) & "#"

The reason being that you are using the Date/Time field and sending it a string and not a date. Hope this helps. [spin]
If you choose to battle wits with the witless be prepared to lose.
[machinegun][hammer]
 
Try this

rs.Filter ="TrainingDate BETWEEN #" & CDate(txtTrainFrom) & "# AND #" & CDate(txtTrainTo) & "#"

The reason being that you are using the Date/Time field and sending it a string and not a date. Hope this helps. [spin]
If you choose to battle wits with the witless be prepared to lose.
[machinegun][hammer]
 
Thank you
I've tried your suggestion, but still keep getting the same error.

What do you think?
 
What type of cursor are you using? If you choose to battle wits with the witless be prepared to lose.
[machinegun][hammer]
 
String or date variable doesn't matter here.
I do not think the BETWEEN is allowed in the filters method. Instead, use
TrainingDate >=#TheDate# AND TrainingDate <=#TheDate#
 
I agree with CCLINT. I think you should try the AND, it should work that way. ----------------
Joe
 
I agree with CCLINT and Joe...

The Operator within the filter statement must be one of the following: <, >, <=, >=, <>, =, or LIKE.

Can't use BETWEEN...




Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top