Report.OnCurrent 属性 (Access)
设置或返回报表上的 OnCurrent 属性的值。 读/写 String。
语法
表达式。OnCurrent
表达 一个代表 Report 对象的变量。
备注
如果希望过程在每次打开特定报表时自动运行,请将窗体的 OnCurrent 属性设置为 [事件过程],Access 会自动存出名为 Private Sub Report_Current () 的过程。
OnCurrent 属性允许以编程方式确定窗体的 OnCurrent 属性的值,或以编程方式设置窗体的 OnCurrent 属性。
注意
在报表) 打开 (运行时, 将触发 Current 事件。
如果在 UI 中设置窗体的 OnCurrent 属性,它将根据你在“选择生成器”窗口中的选择获取其值,该窗口将在报表属性窗口选择“当前”框旁边的“...”按钮时显示。
如果选择“表达式生成器”,则值为 =expression,其中 expression 是“表达式生成器”窗口中的表达式。
如果选择“宏生成器”,则值为宏的名称。
如果选择“代码生成器”,则值为 [事件过程]。
示例
下面的代码示例演示如何设置报表的 OnCurrent 属性。
Private Sub Report_Load()
Me.OnCurrent = "[Event Procedure]"
End Sub
事件过程激发 当前 事件时, Report_Current() 自动调用。 此过程只收集两个报表文本框的值,并将其发送到另一个过程进行处理。
Private Sub Report_Current()
' Declare variables to store price and available credit.
Dim curPrice As Currency
Dim curCreditAvail As Currency
' Assign variables from current values in text boxes on the Report.
curPrice = txtValue1
curCreditAvail = txtValue2
' Call VerifyCreditAvail procedure.
VerifyCreditAvail curPrice, curCreditAvail
End Sub
下面的代码示例只需处理传递给它的两个值。
Sub VerifyCreditAvail(curTotalPrice As Currency, curAvailCredit As Currency)
' Inform the user if there is not enough credit available for the purchase.
If curTotalPrice > curAvailCredit Then
MsgBox "You don't have enough credit available for this purchase."
End If
End Sub
支持和反馈
有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。