The following table explains the available report methods and properties. The remainder of this section explains some of the more common methods and properties you’ll use in when working with reports:
Property/Method |
Description |
---|---|
Cancel method |
Cancels the report from any report event. |
EventMode property |
Specifies whether report events occur for the original or modified version of the report. |
Legend property |
Specifies the value of a report legend. |
Name property |
Specifies the internal name VBA uses for the report. |
You cancel a report using the Cancel method. The following example cancels a report from the report’s BeforeBody event:
Private Sub Report_BeforeBody(SuppressBand As Boolean) If SalespersonID = "ERIN J." Then RMSalespersonReport.Cancel End If End Sub
If you cancel a report from a report’s band event, the report stops at that band. If you cancel a report from a report’s Start event, no data prints for the report. In all cases, the report’s End event will occur for a canceled report. If the report is printed to the screen, the Cancel method closes the Screen Output window automatically.
Use the Legend property to set or return the value of a legend field in a report. You don’t add a legend field to your project; instead, you use the Legend property’s index parameter to refer to a specific legend field on the report. In addition, you can set or return the value of a legend only in the report’s Start event.
A legend field contains data that’s passed to the report at runtime, before it prints. These fields typically include information about the report, such as the range of records the user chose for the report.
For example, to return the value of the Customer Class legend field, the following Start event procedure includes a reference to the field’s index:
Private Sub Report_Start() If RMCustomerReport.Legend(5) = "AARONFIT0001 - AARONFIT0001" Then 'Cancel the report RMCustomerReport.Cancel End If