Different ways to open an access report using DoCmd.OpenReport

A report has many properties that determine its behaviour. These properties concern the way data are presented, possible filters, how it can be used to enter of edit data etcetera. When you design your report, that is the time you will decide on the defaults for your report. However you may want to use rougly the same report in different ways. A powerful way to change from the design-time default behaviour is using the DocDmd.OpenReport arguments.

OpenReport with ReportName

The basic way to open a report is by supplying the ReportName and keeping all the defaults.


DoCmd.OpenReport ReportName:="Customer"

When opened this way Access interprets the command with defaults as here:


DoCmd.OpenReport ReportName:="Customer", View:=acNormal, DataMode:=acReportPropertySettings, WindowMode:=acWindowNormal 
Builder Open Report

OpenReport View

The view in which the report will open. acViewReport shows you the data, acViewPreview the print preview.

OpenReport WindowMode

The default value acWindowNormal shows the report as normally done in Access. Using acDialog causes the report's Modal and PopUp properties to be set to Yes. With acDialog your calling code should not continue until the report is closed.

OpenReport using FilterName

FilterName refers to a query in the current database. You can use either an existing query or a filter that was saved as a query. You can use it both for getting a subset and for having it sorted.

OpenReport WhereCondition

A valid SQL WHERE clause (without the word WHERE) to select records from the report's underlying table or query. If you select a filter with the Filter Name argument, Access applies this WHERE clause to the results of the filter.

To open a report and restrict its records to those specified by the value of a control on a form, use the following expression:

[fieldname] = Forms![formname]![controlname on the form]

Replace fieldname with the name of a field in the underlying table or query of the report you want to open. Replace formname and controlname on form with the name of the form and the control on the form that contains the value you want records in the report to match.

OpenReport OpenArgs

OpenArgs gives an opportunity to pass data to the report which it then can pick up in the Report_Open event. An example of how to do that can be found here