Report.OnCurrent 屬性 (Access)

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

語法

運算式OnCurrent

表達 代表 Report 物件的變數。

註解

如果您想要在每次開啟特定報表時自動執行程式,請將表單的 OnCurrent 屬性設定為 [Event Procedure],而 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 支援與意見反應