OpenReport Macro Action

You can use the OpenReport action to open a report in Design view (Design view: A view that shows the design of these database objects: tables, queries, forms, reports, and macros. In Design view, you can create new database objects and modify the design of existing objects.) or Print Preview (print preview: A view of a document as it will appear when you print it.), or to send the report directly to the printer. You can also restrict the records (record: A collection of data about a person, a place, an event, or some other item. Records are the logical equivalents of rows in a table.) that are printed in the report.

Setting

The OpenReport action has the following arguments.

Action argument Description
Report Name

The name of the report to open. The Report Name box in the Action Arguments section of the Macro Builder pane shows all reports in the current database. This is a required argument.

If you run a macro containing the OpenReport action in a library database (library database: A collection of procedures and database objects that you can call from any application. In order to use the items in the library, you must first establish a reference from the current database to the library database.), Microsoft Office Access 2007 first looks for the report with this name in the library database, and then in the current database.

View The view in which the report will open. Click Print (print the report immediately), Design, or Print Preview in the View box. The default is Print.
Filter Name A filter (filter: A set of criteria applied to data in order to display a subset of the data or to sort the data. In Access, you can use filtering techniques, such as Filter By Selection and Filter By Form, to filter data.) that restricts the report's records. You can enter the name of either an existing query (query: A question about the data stored in your tables, or a request to perform an action on the data. A query can bring together data from multiple tables to serve as the source of data for a form or report.) or a filter that was saved as a query. However, the query must include all the fields in the report you are opening or have its OutputAllFields property set to Yes.
Where Condition

A valid SQL WHERE clause (WHERE clause: The part of an SQL statement that specifies which records to retrieve.) (without the word WHERE) or expression (expression: Any combination of mathematical or logical operators, constants, functions, and names of fields, controls, and properties that evaluates to a single value. Expressions can perform calculations, manipulate characters, or test data.) that Access uses to select records from the report's underlying table (table: A database object that stores data in records (rows) and fields (columns). The data is usually about a particular category of things, such as employees or orders.) 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 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.

 Note   The maximum length of the Where Condition argument is 255 characters. If you need to enter a more complex SQL WHERE clause longer than this, use the OpenReport method of the DoCmd object in a Visual Basic for Applications (VBA) module instead. You can enter SQL WHERE clause statements of up to 32,768 characters in VBA.

Window Mode

The mode in which the report will open. Click Normal, Hidden, Icon, or Dialog in the Window Mode box. The default is Normal.

 Note   Some Window Mode argument settings do not apply when using tabbed documents. To switch to overlapping windows:

  1. Click the Microsoft Office Button Button image, and then click Access Options.
  1. In the Access Options dialog box, click Current Database.
  2. In the Application Options section, under Document Window Options, click Overlapping Windows.
  3. Click OK, then close and reopen the database.

Remarks

The Print setting for the View argument prints the report immediately by using the current printer settings, without bringing up the Print dialog box. You can also use the OpenReport action to open and set up a report and then use the PrintOut action to print it. For example, you may want to modify the report or use the PrintOut action to change the printer settings before you print.

The filter and WHERE condition you apply become the setting of the report's Filter property.

The OpenReport action is similar to double-clicking the report in the Navigation Pane, or right-clicking the report in the Navigation Pane and selecting a view or the Print command.

Tips    

 
 
Applies to:
Access 2007