Report.OnCurrent Property (Access)
Sets or returns the value of the On Current property on the Report. Read/write String.
expression A variable that represents a Report object.
If you want a procedure to run automatically every time you open a particular report, you set the form's On Current 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 On Current property, or to programmatically set the form's On Current property.
Note that the Current event fires when you run (open) a report.
If you set the form's On Current property in the UI, it gets it value based on your selection in the Choose Builder window, which appears when you click the ... button next to On Current in the Report's Properties window.
If you select Code Builder, then the value will be [Event Procedure].
If you select Expression Builder, then the value will be "= expression ", where expression is the expression from the Expression Builder window.
If you select Macro Builder, then the value will be the name of the macro.
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 do not have enough credit available for this purchase." End If End Sub