FormatCount Property

FormatCount Property

See Also                  Applies To

You can use the FormatCount property to determine the number of times the OnFormat property has been evaluated for the current section on a report.

Setting

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

The FormatCount property setting has a Long data type value.

This property isn't available in report Design view and is read-only in other views.

Remarks

Microsoft Access increments the FormatCount property each time the OnFormat property setting is evaluated for the current section. As the next section is formatted, Microsoft Access resets the FormatCount property to 1.

Under some circumstances, Microsoft Access formats a section more than once. For example, you might design a report in which the KeepTogether property for the detail section is set to Yes. When Microsoft Access reaches the bottom of a page, it formats the current detail section once to see if it will fit. If it doesn't fit, Microsoft Access moves to the next page and formats the detail section again. In this case, the setting for the FormatCount property for the detail section is 2 because it was formatted twice before it was printed.

You can use the FormatCount property to ensure that an operation that affects formatting gets executed only once for a section. In the following example, the DLookup function is evaluated only when the FormatCount property is set to 1:

Private Sub Detail_Format(Cancel As Integer, _
     FormatCount As Integer)
    Const conBold = 700
    Const conNormal = 400
    If FormatCount = 1 Then
        If DLookup("CompanyName", _
                "Customers", "CustomerID = Reports!" _
                & "[Customer Labels]!CustomerID") _
                Like "B*" Then
            CompanyNameLine.FontWeight = conBold
        Else
            CompanyNameLine.FontWeight = conNormal
        End If
    End If
End Sub