Report.FormatCount 屬性 (Access)

使用 FormatCount 屬性來判斷針對報表上目前區段評估 OnFormat 屬性的次數。 可讀寫的 Integer

語法

表達。格式計數

代表 Report 物件的變數。

註解

只有在區段的 OnFormat 屬性設定所指定的事件程式中,才能使用此屬性。

在報表設計檢視中不能使用這個屬性。

Microsoft Access 會遞增 FormatCount 屬性目前區段的 OnFormat 屬性設定值會評估每次。 如下一節的格式,Microsoft Access FormatCount 屬性會重設為 1。

在某些情況下,Microsoft Access 將格式設定] 區段中一次以上。 例如,您可能會設計的報告詳細資料區段的 KeepTogether 屬性設定為 Yes。 當 Microsoft Access 達到頁面底部時,一旦查看如果將會配合格式化目前的詳細資料區段。 如果它不配,Microsoft Access 會移至下一個頁面並重新格式化詳細資料區段。 在此例中的 [詳細資料] 區段中的 FormatCount 屬性設定為 2 因為它已格式化兩次之前已列印。

使用 FormatCount 屬性來確保影響格式設定的作業只會針對區段執行一次。

範例

在下列範例中,只有在 FormatCount 屬性設定為 1 時,才會評估 DLookup 函式。

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

支援和意見反應

有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應