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

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

Forum statistics

Threads
1,216,153
Messages
6,129,176
Members
449,491
Latest member
maxim_sivakon

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