QueryDefs and dates (1 Viewer)

Brian1960

Brian1960
Local time
Today, 11:14
Joined
Aug 13, 2004
Messages
141
I have multiple queries in a search form which when selected change the query in the data using QueryDefs.
Set Q = db.QueryDefs("QrySearchEventID")
Q.SQL = strSQLHadEvent
Q.Close

This works fine for the 3 main queries I need to change. These are all then used in a single query with Where ID in (Select ID from QrySearchEventID) etc etc.
These all work like clockwork BUT
One of the SQL statements, strSQLHadEvent, has
Select EventID from Events where EventDate between #" & strStart & "# and #" & StrEnd & "#
as the code. This looks fine in the debug window but by the time it gets into the queryDefs dates revert to US date format when the string shows them both in UK format. All the date formats are UK. dd/mm/yyy in the PC and server.

is there a way of forcing the date formats in access.
 

Brian1960

Brian1960
Local time
Today, 11:14
Joined
Aug 13, 2004
Messages
141
Gave up

Used this instead

Select EventID from Events where CDATE(Format(EventDate,'dd/mm/yyyy')) Between CDate([forms]![frmSearchEvents]![StartDate]) And CDate([forms]![frmSearchEvents]![EndDate])

as trhe queryDef.SQL
 

Users who are viewing this thread

Top Bottom