Report.OnCurrent property (Access)

Sets or returns the value of the OnCurrent property on the report. Read/write String.

Syntax

expression.OnCurrent

expression A variable that represents a Report object.

Remarks

If you want a procedure to run automatically every time you open a particular report, you set the form's OnCurrent property to [Event Procedure] and Access automatically stubs out a procedure for you called Private Sub Report_Current().

The OnCurrent property allows you to programmatically determine the value of the form's OnCurrent property, or to programmatically set the form's OnCurrent property.

Note

The Current event fires when you run (open) a report.

If you set the form's OnCurrent property in the UI, it gets its value based on your selection in the Choose Builder window, which appears when you choose the ... button next to the On Current box in the report's Properties window.

  • If you choose Expression Builder, the value will be =expression, where expression is the expression from the Expression Builder window.

  • If you choose Macro Builder, the value is the name of the macro.

  • If you choose Code Builder, the value will be [Event Procedure].

Example

The following code example demonstrates how to set a report's OnCurrent property.


Private Sub Report_Load()

        Me.OnCurrent = "[Event Procedure]"

End Sub
		

The event procedure Report_Current() is automatically called when the Current event is fired. This procedure simply collects the values of two of the report's text boxes and sends them to another procedure for processing.


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
		

The following code example simply processes the two values passed to it.

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

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.