Good morning
I had a date & time picker in a form, so the user could select a date and a report would then be run from Access. I had to circumvent this when they upgraded access and assume they wanted to run the report based on yesterday. I used the following code, thinking it would work:
The bit that is causing the problem is this:
When the day is the 13th onwards, it works fine, but when it is the 1st to the 12th, it seems to swap the month and the date round and runs the report for the second of January, rather than the first of February.
Any ideas why?
Thanks
Chris
I had a date & time picker in a form, so the user could select a date and a report would then be run from Access. I had to circumvent this when they upgraded access and assume they wanted to run the report based on yesterday. I used the following code, thinking it would work:
Code:
With objaccess
.AutomationSecurity = msoAutomationSecurityLow
.Visible = False
.OpenCurrentDatabase "\\bdifps01\Groups\Platform.Supervisor\DO NOT USE - Log (Front).accdb"
.DoCmd.OpenReport "rptSupervisorsLogHistoric", acViewPreview, , "([DateReported]=#" & DateValue(Now() - 1) & "# And [TimeReported]>=TimeSerial(4,0,0) ) Or ([DateReported]=#" & DateValue(Now()) & "# And [TimeReported]<TimeSerial(4,0,0) )", acHidden
.DoCmd.OutputTo acOutputReport, "rptSupervisorsLogHistoric", acFormatPDF, Folder & "\BDI Supervisors Log for " & Format(DateValue(Now() - 1), "d mmm yy") & ", Created at " & Format(Time, "hhmm") & " on " & Format(Date, "d mmm yy") & ".pdf", , False
.DoCmd.Close acReport, "rptQuote"
.CloseCurrentDatabase
End With
The bit that is causing the problem is this:
Code:
.DoCmd.OpenReport "rptSupervisorsLogHistoric", acViewPreview, , "([DateReported]=#" & DateValue(Now() - 1) & "# And [TimeReported]>=TimeSerial(4,0,0) ) Or ([DateReported]=#" & DateValue(Now()) & "# And [TimeReported]<TimeSerial(4,0,0) )", acHidden
When the day is the 13th onwards, it works fine, but when it is the 1st to the 12th, it seems to swap the month and the date round and runs the report for the second of January, rather than the first of February.
Any ideas why?
Thanks
Chris