ACC2000: How to Implement a dBASE-Style REPORT FORM Command in Visual Basic for Applications (210576)



The information in this article applies to:

  • Microsoft Access 2000

This article was previously published under Q210576
This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).

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

SUMMARY

This article demonstrates how to implement a dBASE-style REPORT FORM command in Visual Basic for Applications.

MORE INFORMATION

In dBASE, you create a report with the Report Generator, and then print the report from a program with the REPORT FORM TO PRINT command. In Microsoft Access, you print a pre-existing report programmatically with DoCmd.OpenReport.

For example, suppose that you created a report in Microsoft Access named MyReport, and you wanted to print the report from a Visual Basic procedure. You would run the following command to do this:
DoCmd.OpenReport "MyReport"
				
If you omit the TO PRINT clause, which is optional in dBASE's REPORT FORM command, the report is 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 acViewPreview parameter:
DoCmd.OpenReport "MyReport", acViewPreview
				
In addition, with the acViewDesign parameter, you can open a report in Design view:
DoCmd.OpenReport "MyReport", acViewDesign
				

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