ACC: How to Use dBASE-Style REPORT FORM Command in Code

ID: Q96101

The information in this article applies to:

SUMMARY

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

This article shows you 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 by using the REPORT FORM TO PRINT command. In Microsoft Access, you can print a pre-existing report programmatically by 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 do 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

Additional query words:
Keywords          : kbprg kbprint
Version           : 1.0 1.1 2.0 7.0 97
Platform          : WINDOWS
Hardware          : x86
Issue type        : kbhowto

Last Reviewed: November 20, 1998