Access) (Report.OnCurrent 屬性

設定或傳回報表上 OnCurrent 屬性的值。 讀取/寫入的 String。

語法

運算式。OnCurrent

運算式 代表 Report 物件的變數。

註解

如果您想要在每次開啟特定報表時自動執行程序,請將表單的 OnCurrent 屬性設為 [事件程序],Access 就會自動存根出稱為 私人子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 支援與意見反應。