Report.FormatCount property (Access)

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. Read/write Integer.



expression A variable that represents a Report object.


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

This property isn't available in report Design view.

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 
 CompanyNameLine.FontWeight = conNormal 
 End If 
 End If 
End Sub

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.