title | keywords | f1_keywords | api_name | ms.assetid | ms.date | ms.localizationpriority | ||
---|---|---|---|---|---|---|---|---|
DoCmd.OpenReport method (Access) |
vbaac10.chm4163 |
|
|
3c08755a-5116-f085-d498-725dc12e62f1 |
03/07/2019 |
high |
The OpenReport method carries out the OpenReport action in Visual Basic.
expression.OpenReport (ReportName, View, FilterName, WhereCondition, WindowMode, OpenArgs)
expression A variable that represents a DoCmd object.
Name | Required/Optional | Data type | Description |
---|---|---|---|
ReportName | Required | Variant | A string expression that's the valid name of a report in the current database. If you execute Visual Basic code containing the OpenReport method in a library database, Microsoft Access looks for the report with this name first in the library database, and then in the current database. |
View | Optional | AcView | An AcView constant that specifies the view in which the report will open. The default value is acViewNormal. |
FilterName | Optional | Variant | A string expression that's the valid name of a query in the current database. |
WhereCondition | Optional | Variant | A string expression that's a valid SQL WHERE clause without the word WHERE. |
WindowMode | Optional | AcWindowMode | An AcWindowMode constant that specifies the mode in which the form opens. The default value is acWindowNormal. |
OpenArgs | Optional | Variant | Sets the OpenArgs property. |
Use the OpenReport method to open a report in Design view or Print Preview, or to print the report immediately. You can also restrict the records that are printed in the report.
The maximum length of the WhereCondition argument is 32,768 characters (unlike the WhereCondition action argument in the Macro window, whose maximum length is 256 characters).
The following example prints Sales Report while using the existing query Report Filter.
DoCmd.OpenReport "Sales Report", acViewNormal, "Report Filter"
[!includeSupport and feedback]