ACC: Using dBASE-Style REPORT FORM Command in Code (96101)



The information in this article applies to:

  • Microsoft Access 1.0
  • Microsoft Access 1.1
  • Microsoft Access 2.0
  • Microsoft Access for Windows 95 7.0
  • Microsoft Access 97

This article was previously published under Q96101
Moderate: Requires basic macro, coding, and interoperability skills.

SUMMARY

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

Modification Type:MinorLast Reviewed:10/11/2006
Keywords:kbhowto kbprint kbProgramming KB96101