Band events

A report is composed of several sections called bands. In VBA, each report band has a corresponding band event. As a report prints, each band event occurs just before the corresponding data within the band prints. The following illustration shows the different bands that compose a report:

[spacer]

The primary use of a band event is to return or set the value of a field in a corresponding band using the Value property. You can use a band event to return a value for any report table field or calculated field. You can set a value only for a user-defined calculated field you’ve added using the Report Writer.

The BeforeAH event procedure can return the value of the Customer Name table field, and set EMailAddress user-defined calculated field:

Private Sub Report_BeforeAF(By Val Level As Integer, SuppressBand _
As Boolean)
	If CustomerName = "Aaron Fitz Electric" Then
		'Set the user-defined calculated field
		EMailAddress = "aftiz@aol.com"
	End If
End Sub

Each band event includes a SuppressBand parameter. When set to True, the SuppressBand parameter stops the current instance of the corresponding band from printing. If a band prints multiple times in a report (such as the report body), you can conditionally suppress a given instance of the band. For example, the following BeforeBody procedure for the RM Salesperson Report suppresses the current instance of the report body if the value of the Commissioned Sales To Date field is less then $200,000:

Private Sub Report_BeforeBody(SuppressBand As Boolean)
	If CCur(CommissionedSalesToDate) < 200000 Then
		SuppressBand = True
	End If
End Sub

If the report uses an accumulator field to calculate report totals or count the number of bodies in a report, the accumulator field will still sum or count data from fields in a suppressed band.


BeforePH event

The BeforePH event occurs before items in the page header print. Items in the page header are placed at the top of every report page. Page number, date and time fields are commonly placed in this section of a report.

BeforeRH event

The BeforeRH event occurs before items in the report header print. Items in the report header appear only on the first page of a report. The title of the report and introductory information are often included in this section. If a page header is also included on the first page, the report header will appear after the page header.

BeforeAH event

The BeforeAH event occurs before the report’s additional header prints. A report may have none, one or several additional headers, each indicated on the report layout by H1, H2 and so on. Each prints when the data in the field it is based on changes.

If a report uses multiple additional headers, use the BeforeAH event’s Level parameter to specify an index corresponding to the number of the additional header the event occurs for. In the following example, the BeforeAH event procedure runs for the second additional header on a report. The procedure also returns the value of the Checkbook ID field in the second additional header:

Private Sub Report_BeforeAH(By Val Level As Integer, SuppressBand _
As Boolean)
	If Level = 2 Then
		If CheckbookID = "PAYROLL" Then
			BankDepositPostingJournal.Cancel
		End If
	End If
End Sub

If the report has only one additional header, the BeforeAH event occurs only for that additional header, and you don’t need to specify a value for the Level parameter.

BeforeBody event

The BeforeBody event occurs before each instance of the report’s body prints. Microsoft Dynamics GP uses the report body for the bulk of a report, which typically is made up of table fields. A report prints the body repeatedly until all records in the report have printed.

BeforeRF event

The BeforeRF event occurs before the report footer prints. Items in the report footer appear only on the last page of a report. Summary information is often included the report footer. If a page footer is also included on the last page, the report footer will print before the page footer.

BeforePF event

The BeforePF event occurs before the report’s page footer prints. Items in the page footer are placed at the bottom of every report page. The page footer often includes administrative information, such as the name of the person running the report.

BeforeAF event

The BeforeAF event occurs before the report’s additional footer prints. A report may have none, one or several additional footers, each indicated on the report layout by F1, F2 and so on. Each prints when the data in the field it is based on changes. Microsoft Dynamics GP uses the additional footer to display summary data, such as a total of all records in the report’s body.

If a report uses more than one additional footer, use the BeforeAF event’s Level parameter to specify an index corresponding to the number of the additional header you want the event to occur for. In the following example, the BeforeAF event procedure runs for the second additional footer that appears on the report:

Private Sub Report_BeforeAF(By Val Level As Integer, SuppressBand _
As Boolean)
	If Level = 2 Then
		If CustomerName = "Aaron Fitz Electric" Then
		'Set the user-defined calculated field
			EMailAddress = "aftiz@aol.com"
		End If
	End If
End Sub

If the report has only one additional footer, the BeforeAF event occurs only for that additional footer, and you don’t need to specify a value for the Level parameter.


Documentation Feedback