DoCmd.OpenReport (Access)
The OpenReport method carries out the OpenReport action in Visual Basic.
You can 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).
OpenReport (ReportName, View, FilterName, WhereCondition, WindowMode, OpenArgs)
DoCmd.OpenReport "Sales Report", acViewNormal, "Report Filter"
Arguments
The following argument is required
ReportName (String) - 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.
Optional arguments
The following arguments are optional
View (AcView) - An AcView constant that specifies the view in which the report will open. The default value is acViewNormal.
Possible values are
acViewDesign | Design view |
acViewLayout | Layout view |
acViewNormal | Normal view |
acViewPivotChart | PivotChart view |
acViewPivotTable | PivotTable view |
acViewPreview | Print Preview |
acViewReport | Report view |
FilterName (String) - A string expression that's the valid name of a query in the current database.
WhereCondition (String) - A string expression that's a valid SQL WHERE clause without the word WHERE.
WindowMode (AcWindowMode) - An AcWindowMode constant that specifies the mode in which the form opens. The default value is acWindowNormal.
Possible values are
acDialog | The form or report's Modal and PopUp properties are set to Yes. |
acHidden | The form or report is hidden. |
acIcon | The form or report opens minimized in the Windows taskbar. |
acWindowNormal | The form or report opens in the mode set by its properties. |
OpenArgs (String) - Sets the OpenArgs property.