databasedev.co.uk - database solutions and downloads for microsoft access

Create Better MS Access Reports
Report Builder for Microsoft Access helps you create dynamic, professional-looking reports fast! The easy-to-understand wizard helps you with complex tasks like calculated fields, adding subreports, customizing styles, as well as grouping and sorting. Download a free trial today!

Microsoft Access Report Preview

Previewing a Microsoft Access report sized using acCmdZoom:

When we open a Microsoft Access report in Print Preview we have options available to us about how we would like to see and view the report on the screen. We can use the Zoom options on the Print Preview toolbar to allow us to resize the preview of the report to make it easily visible. The Zoom dropdown list allow us to set various sizes for the report, and includes values such as 10%, 25%, 50% amongst others, and is displayed below:

The zoom dropdown list, available from the Print Preview toolbar
The zoom dropdown list, available from the Print Preview toolbar

We can programmatically set the zoom size of a report, when opening it in code, by using the RunCommand action. We can use the RunCommand action to run a built-in Microsoft Access commands, which often appear on menu bars, toolbars or shortcut menus.

If we are opening a report from a form, we will use code behind the command button to open the report as shown below:

Form that we will be opening the report from

Private Sub cmdReportPreview_Click()
On Error GoTo Err_cmdReportPreview_Click

    Dim stDocName As String

    stDocName = "rptEmployees"
    DoCmd.OpenReport stDocName, acPreview
    DoCmd.Maximize
    DoCmd.RunCommand acCmdZoom25

Exit_cmdReportPreview_Click:
    Exit Sub

Err_cmdReportPreview_Click:
    MsgBox Err.Description
    Resume Exit_cmdReportPreview_Click
    
End Sub

You will see that we have included the RunCommand action of:

    DoCmd.RunCommand acCmdZoom25

Using this at this setting will display the preview of the report at 25% of the maximized database window. We can alter the zoom value to display at any given size from: 10, 25, 50, 75, 100, 150, 200, 500 or 1000 %

You can see how this appears in your database in the following example:

Showing the report displaying at 25% of its size in the database window.
Showing the report displaying at 25% of its size in the database window.

The code can be used to set the size of the report preview to any of these given sizes. If we need to display the report at any other size (i.e. custom sizes) then we will need to use the ZoomControl property of the Report object. Details of this can be seen in the article over at The Access Web - Custom Zoom in Reports

Also check out: Use RunCommand to Open Access Reports in Whatever Size You Want