Called when there have been any changes made to the Recordset.
The RecordsetChangeComplete event can be fired when a call to the Open or
Requery methods has caused a change in the contents of a Recordset.
If the provider does not support bookmarks, this event will fire each time the Recordset cache is
updated by ADO.
In contrast, the WillChangeRecordset event can be fired before any pending changes occur
in the Recordset.
An event is simply a subroutine that can be called automatically after a specific operation has occurred.
This subroutine can contain any code that you need to run when the event occurs.
The subroutine will only be called if it is included in your code.
There are four parameters passed to this event.
EventReasonEnum Constants
Constant | Value | Description |
---|---|---|
adRsnClose | 9 | The Recordset has been closed |
adRsnMove | 2 | The record pointer has been moved in the Recordset |
adRsnRequery | 11 | The Recordset has been requeried |
adRsnResynch | 5 | The Recordset has been resynchronized with the data source |
Constant | Value | Description |
---|---|---|
adStatusCancel | 4 | Cancels the operation that fired the event |
adStatusCantDeny | 3 | Cannot cancel pending operation |
adStatusErrorsOccurred | 2 | Indicates that warnings and/or errors occurred |
adStatusOK | 1 | The operation that fired the event was successful |
adStatusUnwantedEvent | 5 | The operation that generated the event cannot generate future events |
' Use the WithEvents keyword to designate that events
' can be handled by this Recordset object
Dim WithEvents objRecSet As ADODB.Recordset
' Note how the object name, objRecSet, is incorporated into the event Sub name
Private Sub objRecSet_RecordsetChangeComplete( adReason As ADODB.EventReasonEnum, _
ByVal pError As ADODB.Error, _
adStatus As ADODB.EventStatusEnum, _
ByVal pRecordset As ADODB.Recordset )
' place any code you desire here, for example
If adStatus = adStatusErrorsOccurred Then
Dim objError As ADODB.Error
For Each objError in pRecordset.Errors
Debug.Print vbtab; objError.Description
Next
End If
End Sub