'Serving the Microsoft® Access
Community since 1997'

Free Samples
About Us



Report Preview Tips - Part 1

Here are two tips to use when creating a report preview. Although I seldom use these particular ideas, I think that they are worthwhile ones to keep in your VBA "bag of tricks".

NOTE: All the VBA code segments on the Database Lessons site assume that you have DAO references active. If you are not sure what this means, and you are using Microsoft Access 2000 or higher, click here.

(article continues after sponsor spot)

Default the Report Preview to Full page

When previewing reports, there are times when it is convenient to have the preview open at a particular zoom, or magnification

'--- open the report in preview mode
DoCmd.OpenReport strReport, acViewPreview
'--- change the report's zoom to show the entire first page
Application.RunCommand acCmdPreviewOnePage

'--- change the zoom to a specific level (choose one of the following)
DoCmd.RunCommand acCmdZoom10
DoCmd.RunCommand acCmdZoom25
DoCmd.RunCommand acCmdZoom50
DoCmd.RunCommand acCmdZoom75
DoCmd.RunCommand acCmdZoom100
DoCmd.RunCommand acCmdZoom150
DoCmd.RunCommand acCmdZoom200

Getting a Form to Wait for a Report Preview

I am sure there are times when you want to present a user with a report preview, and know when they have closed it.

'--- open the report in preview mode
DoCmd.OpenReport strReport, acViewPreview
'--- as long as the report is open, wait
If SysCmd(acSysCmdGetObjectState, A_REPORT, _
      strReport) = OBJSTATE_OPEN Then '(put on same line as previous 'If')
   DoCmd.Maximize '--- maximize the form so that the report will be as well
   Me.Visible = False '--- make the calling form invisible (optional)
   Do While SysCmd(acSysCmdGetObjectState, A_REPORT, _
      strReport) = OBJSTATE_OPEN '(put on same line as previous 'Do')
   Me.Visible = True
   DoCmd.Restore '--- restore form to normal size
End If

Further Suggestions:

To make sure that you find out whenever we are adding more tips, subscribe to our newsletter. Just click the Subscribe button to the left to start the process.

Happy Coding

Note: This web site dedicated to MS Access database users is an independent publication of Richard W. Killey and is not affiliated with, nor has it been authorized, sponsored, or otherwise approved by Microsoft® Corporation.


© 2006, 2007, 2008 Richard W. Killey. All Rights Reserved. - Privacy Policy