Docmd.OpenReport and Docmd.OutputReport

ccordner

Active Member
Joined
Apr 28, 2010
Messages
355
I have some code, below.

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
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).

Forum statistics

Threads
1,215,219
Messages
6,123,678
Members
449,116
Latest member
HypnoFant

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top