I have some code, below.
This code is in Excel 2007 and successfully opens a report in Access (2007), saves it as a PDF in the right Year/Month folder for me.
What I want to do is do a filtered report, based on this. So I added the line:
Above the Output report. But, it only returns IncidentNumber= 3474. It then opens the "Save As" box. and runs the following line with the report (but unfiltered).
So I think what I need is a way of combining the two statements and allowing the OR statement.
P.S. The IncidentNumber criteria were just to test. What I actually want is something like:
Thanks
Chris
Code:
Set objaccess = CreateObject("Access.Application")
With objaccess
.AutomationSecurity = msoAutomationSecurityLow
.Visible = False
.OpenCurrentDatabase "Path\Log(Front).accdb"
.DoCmd.OutputTo acOutputReport, "rptSupervisorsLogPreviousDay", acFormatPDF, "Path\Supervisors Log for " & Format(Date - 1, "d") & " " & Format(Date - 1, "mmm") & " " & Format(Date - 1, "yy") & ", Created at " & Format(Time, "hhmm") & " on " & Format(Date, "d mmm yy") & ".pdf", , False
.CloseCurrentDatabase
End With
This code is in Excel 2007 and successfully opens a report in Access (2007), saves it as a PDF in the right Year/Month folder for me.
What I want to do is do a filtered report, based on this. So I added the line:
Code:
.DoCmd.OpenReport "rptSupervisorsLogPreviousDay", acNormal, , "[IncidentNumber] =" & 3474 & " OR " & 3475
Above the Output report. But, it only returns IncidentNumber= 3474. It then opens the "Save As" box. and runs the following line with the report (but unfiltered).
So I think what I need is a way of combining the two statements and allowing the OR statement.
P.S. The IncidentNumber criteria were just to test. What I actually want is something like:
Code:
WHERE (IncidentDate=Today-1 and IncidentTime>=4:00am) OR (IncidentDate=Today and IncidentTime<4:00am)
Thanks
Chris