共用方式為


Report.Page 事件 (存取)

Page 事件發生於 Microsoft Access 設定列印報表的頁面格式之後,但是在列印該頁之前。 使用此事件在頁面周圍繪製框線,或將其他圖形元素新增至頁面。

語法

運算式網頁

表達 代表 Report 物件的變數。

傳回值

註解

若要在此事件發生時執行宏或事件程序,請將 OnPage 屬性設定為宏的名稱或 [事件程序]。

此事件會在報表的所有 Format 事件之後,以及在頁面的所有 Print 事件之後,但在實際列印頁面之前發生。

您通常會在Page事件程序中使用LineCirclePSet方法來建立頁面所需的圖形。

NoData事件會發生在報表的第一個Page事件之前。

範例

下列範例顯示如何使用 Line 方法在報表頁面周圍上畫出一個矩形。 根據預設,ScaleWidthScaleHeight 屬性會傳回報表的內部寬度和高度。

Private Sub Report_Page() 
    Me.Line(0, 0)-(Me.ScaleWidth, Me.ScaleHeight), , B 
End Sub

下列範例會示範如何將浮水印新增至報表會在列印之前使用 Page事件。

Private Sub Report_Page()
    Dim strWatermarkText As String
    Dim sizeHor As Single
    Dim sizeVer As Single

#If RUN_PAGE_EVENT = True Then
    With Me
        '// Print page border
        Me.Line (0, 0)-(.ScaleWidth - 1, .ScaleHeight - 1), vbBlack, B
    
        '// Print watermark
        strWatermarkText = "Confidential"
        
        .ScaleMode = 3
        .FontName = "Segoe UI"
        .FontSize = 48
        .ForeColor = RGB(255, 0, 0)

        '// Calculate text metrics
        sizeHor = .TextWidth(strWatermarkText)
        sizeVer = .TextHeight(strWatermarkText)
        
        '// Set the print location
        .CurrentX = (.ScaleWidth / 2) - (sizeHor / 2)
        .CurrentY = (.ScaleHeight / 2) - (sizeVer / 2)
    
        '// Print the watermark
        .Print strWatermarkText
    End With
#End If

End Sub

支援和意見反應

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