BeforeCommitTransaction Event

Microsoft Access Visual Basic

Show All

BeforeCommitTransaction Event

       

Occurs just before Microsoft Access signals to the server to commit all the changes in a batch transaction to the underlying data on the server.

Private Sub Form_BeforeCommitTransaction(Cancel As Integer, Connection As ADODB.Connection)

Cancel   Setting this argument to True cancels the commitment of the batch transaction, retains all pending changes on the form, and rolls back the batch transaction on the server.

Connection   The connection on which the batch transaction is taking place.

Remarks

This event applies to Access project forms whose BatchUpdates properties are set to True.

When this event occurs, all changes have been made, no errors have occurred, and Access is ready to make the changes permanent. Any changes to the data at this point are made inside the batch transaction.

Example

The following example demonstrates the syntax for a subroutine that traps the BeforeCommitTransaction event.

Private Sub Form_BeforeCommitTransaction( _
        Cancel As Integer, Connection As ADODB.Connection)
    Dim intResponse As Integer
    Dim strPrompt As String

    strPrompt = "Access is about to commit the batch transaction on " _
        & Connection.Name & ". Do you wish to continue?"

    intResponse = MsgBox(strPrompt, vbYesNo)

    If intResponse = vbNo Then
        Cancel = True
    Else
        Cancel = False
    End If
End Sub