Microsoft Access 2007 tutorial: open report from form

Open report from form

II.3. Open a Report from a Form

Opening the report from the form is important when you want to see the report while you are opening the form. It saves the time because you no need to find the report that you want to open on the navigation pane. To open the report from the form, there is a method that you need to know and you must have one form and one report. For example, there is the form book(frmBookInfo) as figure:

Microsoft Access 2007-Form Book

The frmBookInfo form has a command button(Print Report). When you clicks this button, the report will display like figure:

Microsoft Access 2007- Report View

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
End Sub

Code explanation:

- 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:
C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word. However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.