FormatCount Property

Applies To

Report.

Description

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 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 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.

Use the FormatCount property to ensure that a time-consuming 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 1.


If FormatCount = 1 Then
    If DLookup("[CustomerName]","[Customers]", "[CustomerID] = _
    Reports![Customers]![CustomerID]") = 7 Then
        [CustomerName].FontWeight = Bold
    Else
        [CustomerName].FontWeight = Normal
    End IfIf

If you include the Else block in this procedure, you don’t need to create an OnRetreat event procedure for the section.

Tip To calculate totals, use the PrintCount property.

See Also

Format Event, PrintCount Property.