G
Guest
I am using the below code to generate an SQL statement. It works OK but there
is some kind of weird behaviour going on with the dates.
I am using Active X Calenders to generate the start and end dates and I have
added 2 debug statements to check the dates. In the Debug window it is
printing the correct uk dates ie: 01/04/2004 and the SQL statement in the
debug window also displays the correct date but when this value is parsed to
the query it changes to 04/01/2004! If I select a date like 30/09/2004 it
will the parse the correct date to the query but when the date could be
either UK or USA format it chooses USA format.
Has anyone ever experienced this before?
If subfrmDateRange!ActiveXCtl4.Value = Date Then
MsgBox ("You cannot run report for today only?")
Exit Sub
Else
If subfrmDateRange!ActiveXCtl4.Value > subfrmDateRange!ActiveXCtl1.Value
Then
MsgBox ("The Start Date must be before the end Date")
Exit Sub
Else
dtStartDate = subfrmDateRange!ActiveXCtl4.Value
dtEndDate = subfrmDateRange!ActiveXCtl1.Value
MsgBox ("Date Range " & dtStartDate & "-" & dtEndDate)
End If
End If
Debug.Print dtStartDate
Debug.Print dtEndDate
strSQL = "SELECT qryAllinfo.SuppCode, tblSuppliers.SupplierName,
qryAllinfo.GLCode, qryAllinfo.AccountDescription, " & _
"qryAllinfo.Date, qryAllinfo.Amount, qryAllinfo.Industry " & _
"FROM tblSuppliers INNER JOIN qryAllinfo ON
tblSuppliers.SupplierCode = qryAllinfo.SuppCode " & _
"WHERE qryAllinfo.Date Between #" & dtStartDate & "# AND #" &
dtEndDate & "# AND qryAllinfo.Industry " & strCommodity & ";"
is some kind of weird behaviour going on with the dates.
I am using Active X Calenders to generate the start and end dates and I have
added 2 debug statements to check the dates. In the Debug window it is
printing the correct uk dates ie: 01/04/2004 and the SQL statement in the
debug window also displays the correct date but when this value is parsed to
the query it changes to 04/01/2004! If I select a date like 30/09/2004 it
will the parse the correct date to the query but when the date could be
either UK or USA format it chooses USA format.
Has anyone ever experienced this before?
If subfrmDateRange!ActiveXCtl4.Value = Date Then
MsgBox ("You cannot run report for today only?")
Exit Sub
Else
If subfrmDateRange!ActiveXCtl4.Value > subfrmDateRange!ActiveXCtl1.Value
Then
MsgBox ("The Start Date must be before the end Date")
Exit Sub
Else
dtStartDate = subfrmDateRange!ActiveXCtl4.Value
dtEndDate = subfrmDateRange!ActiveXCtl1.Value
MsgBox ("Date Range " & dtStartDate & "-" & dtEndDate)
End If
End If
Debug.Print dtStartDate
Debug.Print dtEndDate
strSQL = "SELECT qryAllinfo.SuppCode, tblSuppliers.SupplierName,
qryAllinfo.GLCode, qryAllinfo.AccountDescription, " & _
"qryAllinfo.Date, qryAllinfo.Amount, qryAllinfo.Industry " & _
"FROM tblSuppliers INNER JOIN qryAllinfo ON
tblSuppliers.SupplierCode = qryAllinfo.SuppCode " & _
"WHERE qryAllinfo.Date Between #" & dtStartDate & "# AND #" &
dtEndDate & "# AND qryAllinfo.Industry " & strCommodity & ";"