markbeserra
Technical User
Hi all,
I am having some difficulty in my project trying to allow a User to select records between dates.
I get the following error when two dates (StartDate) and (EndDate) are entered in to the text boxes and the query is run.
Run-time error '13'
Type mismatch
I don't know if the problem is in my code or if the problem exists in the date/time format.
The query will return the correct records when the following is entered directly into the criteria field of the query.
Between #3/19/2001# And #3/22/2001#
The code I'm using allows for the User to make multiple selections from other fields for the query (concatinating Where Statements). Specifically the code for the date text boxes I"m using is as follows:
If Not IsNull(Me![EndDate]) Then
where = where & " AND [TransactionDate] between #" + _
Me![StartDate] + "# AND #" & Me![EndDate] & "#"
Else
where = where & " AND [TransactionDate] >= #" + Me![StartDate] _
+ " #"
End If
I hope this passes the correct syntax for the Query.
Now for the Date/Time format, the table that is being queried formats the Date/Time as 'General Date'. When I directly enter a 'Short Date' format into the Query criteria field, a correct query returns. The Text boxes in which the User enters the date is formatted as 'Short Date'.
So, I'm not sure if the formatting is the problem here.
The other code works great for all other parts of this form except for the date portion.
Can anyone help?
Thanks,
Mbeserra
I am having some difficulty in my project trying to allow a User to select records between dates.
I get the following error when two dates (StartDate) and (EndDate) are entered in to the text boxes and the query is run.
Run-time error '13'
Type mismatch
I don't know if the problem is in my code or if the problem exists in the date/time format.
The query will return the correct records when the following is entered directly into the criteria field of the query.
Between #3/19/2001# And #3/22/2001#
The code I'm using allows for the User to make multiple selections from other fields for the query (concatinating Where Statements). Specifically the code for the date text boxes I"m using is as follows:
If Not IsNull(Me![EndDate]) Then
where = where & " AND [TransactionDate] between #" + _
Me![StartDate] + "# AND #" & Me![EndDate] & "#"
Else
where = where & " AND [TransactionDate] >= #" + Me![StartDate] _
+ " #"
End If
I hope this passes the correct syntax for the Query.
Now for the Date/Time format, the table that is being queried formats the Date/Time as 'General Date'. When I directly enter a 'Short Date' format into the Query criteria field, a correct query returns. The Text boxes in which the User enters the date is formatted as 'Short Date'.
So, I'm not sure if the formatting is the problem here.
The other code works great for all other parts of this form except for the date portion.
Can anyone help?
Thanks,
Mbeserra