Format Event — Event Procedures Example
The following example displays or hides a congratulatory message next to a calculated control that shows sales totals by salesperson. In report sections where the sales total is greater than the sales goal, a label named Message displays the message "Congratulations! You have met your sales goal" when the section is printed; in sections where the sales total is less than the sales goal, the label is hidden.
To try the example, add the following event procedure to a report that contains a label called Message, a text box called GrandTotal (a calculated control that displays the sales total), and a detail section called SalesDetail.
Private Sub SalesDetail_Format(Cancel As Integer, _
FormatCount As Integer)
Const conSalesGoal = 1000
If Me!GrandTotal > conSalesGoal Then
Me!Message.Visible = True
Else
Me!Message.Visible = False
End If
End Sub