ACC: Using dBASE-Style REPORT FORM Command in Code

Last reviewed: August 29, 1997
Article ID: Q96101
The information in this article applies to:
  • Microsoft Access versions 1.0, 1.1, 2.0, 7.0, 97

SUMMARY

Moderate: Requires basic macro, coding, and interoperability skills.

This article discusses how to implement a dBASE-style REPORT FORM command in Visual Basic for Applications (or Access Basic in versions 1.x and 2.0).

MORE INFORMATION

In dBASE, you can create a report with the Report Generator and then print the report from a program using the REPORT FORM TO PRINT command. In Microsoft Access, you can print a pre-existing report programmatically using DoCmd.OpenReport (or DoCmd OpenReport in versions 1.x and 2.0).

For example, suppose you have created a report in Microsoft Access called MyReport, and you want to print the report from a Visual Basic procedure. Use the following command to accomplish this:

NOTE: If you are using Microsoft Access version 2.0 or earlier, replace "DoCmd.OpenReport" with "DoCmd OpenReport" (without the quotation marks) in the following examples.

   DoCmd.OpenReport "MyReport"

If you omit the TO PRINT clause, which is optional in dBASE's REPORT FORM command, the report will be printed to the screen. This is equivalent to showing the report in Print Preview mode rather than sending it to the printer. This can be done with DoCmd.OpenReport by adding the A_PREVIEW parameter:

   DoCmd.OpenReport "MyReport", A_PREVIEW

In Addition, you can open a report in Design view by using the A_DESIGN parameter:

   DoCmd.OpenReport "MyReport", A_DESIGN
Keywords          : kbprg kbprint PgmOthr
Version           : 1.0 1.1 2.0 7.0 97
Platform          : WINDOWS
Hardware          : x86
Issue type        : kbhowto


================================================================================


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: August 29, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.