設定或傳回報表上 OnCurrent 屬性的值。 讀取/寫入的 String。
語法
表達。當前
詞 代表 Report 物件的變數。
註解
如果您想要每次開啟特定報表時自動執行程序,請將表單的 OnCurrent 屬性設定為 [事件程序],Access 會自動為您存根稱為 Private Sub Report_Current () 的程序。
OnCurrent 屬性可讓您以程式設計方式判斷表單 OnCurrent 屬性的值,或以程式設計方式設定表單的 OnCurrent 屬性。
注意事項
當您執行 (開啟) 報表時,會引發目前事件。
如果您在 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 支援與意見反應。