The Reports Collection and Report Object

The Reports collection contains all the open reports in the application, and a Report object refers to a specific report. Look at another example. The modBusinessLogic standard module can be added to the database to store the sub procedures used in the remaining examples. Suppose you have the following TestReports procedure in the modBusinessLogic standard module in your database.

Sub TestReports()

Dim rptReport As Report

'loop through each open report in the reports collection 'and display the name in the Immediate window For Each rptReport In Reports

Debug.Print rptReport.Name Next rptReport

End Sub

Notice how a local variable called rptReport is first declared as a Report object, and then the program loops through each Report object in the Reports collection to print the name of the report to the Immediate Window. If any report is currently open in your database, you see the report name in the Immediate Window (after you run the preceding code) if you type TestReports and press Enter. Otherwise, you get a blank response to indicate that no reports are currently open.

0 0

Post a comment