The frmBookInfo form has a command button(Print Report). When you clicks this button, the report will display like figure:
To open the report from the form, you needs to use a method(Docmd.OpenReport) and attach the code to cmdPrintReport:
Private Sub cmdPrintReport_Click()
DoCmd.OpenReport "Report1", acViewReport
- Docmd.OpenReport: It is the command or method to open the report.
- Report1: Name of the report.
- AcViewReport: The view mode of the report to open.
Note: There are 7 modes to open the report:
- AcViewDesign: Open the report in design view. This mode allows the user to make the changes such as editing, adding the controls, adding the group & sort, using aggregate functions, and setting the conditional on the report.
- AcViewLayout: Open the report in layout view. This mode actually runs the report because you can see the data while you are modifying the report. In layout view, you can set the conditions, add the group and sort, set the column width, color and style.
- AcViewNormal: Print the report if your computer is connected to the printer. If you don't have the printer, it will send to Microsoft Office OneNote 2007(if you install Microsoft Office 2007).
- AcViewPivotChat: Open the report in PivoteChat view.
- AcViewPivotTable: Open the report in PivotTable view.
- AcViewPreview: Open the report in print preview view. This mode allows you to zoom in or zoom out the report.
- AcViewReport: Open the report in Report View. This mode shows all the data of the report but you cannot edit the report(Read Only).
This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages: