Report.Page 事件 (Access)

Page 事件发生在 Microsoft Access 对一个要打印的报表页设置格式之后,但在该页被打印之前。 使用此事件可围绕页面绘制边框,或向页面添加其他图形元素。

语法

表达式网页

表达 一个代表 Report 对象的变量。

返回值

Nothing

注解

若要在发生此事件时运行宏或事件过程,请将 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 支持和反馈,获取有关如何接收支持和提供反馈的指南。