PrintCount Property

Microsoft Access Visual Basic

property has been evaluated for the current section of a report. Read/write Integer.

expression.PrintCount

expression    Required. An expression that returns one of the objects in the Applies To list.

Remarks

You can use this property only in a macro or an event procedure specified by a section's OnPrint property setting.

This property isn't available in report Design view.

Microsoft Access increments the PrintCount property each time the OnPrint property setting is evaluated for the current section. As the next section is printed, Microsoft Access resets the PrintCount property to 0.

The PrintCount property is incremented, for example, when the KeepTogether property is set to No for the current section and the section is printed on more than one page. If you print a report containing order information, you might keep a running total of the order amounts.

Example

The following example shows how you can use the PrintCount property to make sure the value in the OrderAmount control is added only once to the running total:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    If PrintCount = 1 Then
        RunningTotal = RunningTotal + OrderAmount
    End If
End Sub
		

In the previous example, RunningTotal can be a public variable or the name of an unbound control that is incremented each time a section is printed.