How can i modify this date field code to accept wildcards?
Hi guys.
I'm using the query by form method, and am searching for dates. Here's the code i have at the moment which searches for exact dates only (this works fine):
If Not IsNull(Me![SrchDateOfDeparture]) Then
where = where & " AND [DateOfDeparture]= #" & Format(Me![SrchDateOfDeparture], "mm/dd/yyyy") & "#"
End If
SrchDatefDeparture is the name of the unbound field in the search form. DateOfDeparture is the actual field name in the query/table. As you can see i've formatted it so that i don't get problems with UK/US formats (when searching for 12/04/2004 etc). I need to modify the code above so that the user can search for */12/2003 (all trips in dec 2003) or */12/* (all trips in dec) or whatever. I don't have a clue how to do this. I understand you can do stuff like:
select * from table where month( [datefield] ) = 01
select * from table where year( [datefield] ) = 1982
select * from table where day( [datefield] ) = 27
etc but i don't know how that helps me.
Anyone got any ideas? Many thanks in advance
Hi guys.
I'm using the query by form method, and am searching for dates. Here's the code i have at the moment which searches for exact dates only (this works fine):
If Not IsNull(Me![SrchDateOfDeparture]) Then
where = where & " AND [DateOfDeparture]= #" & Format(Me![SrchDateOfDeparture], "mm/dd/yyyy") & "#"
End If
SrchDatefDeparture is the name of the unbound field in the search form. DateOfDeparture is the actual field name in the query/table. As you can see i've formatted it so that i don't get problems with UK/US formats (when searching for 12/04/2004 etc). I need to modify the code above so that the user can search for */12/2003 (all trips in dec 2003) or */12/* (all trips in dec) or whatever. I don't have a clue how to do this. I understand you can do stuff like:
select * from table where month( [datefield] ) = 01
select * from table where year( [datefield] ) = 1982
select * from table where day( [datefield] ) = 27
etc but i don't know how that helps me.
Anyone got any ideas? Many thanks in advance