RecordChangeComplete Event
Error Object
CursorType Property
Record Object
EVENT: Recordset::WillChangeRecord
WillChangeRecord
(adReason, cRecord, adStatus, pRecordset)
The
WillChangeRecord
event can be fired before the values for one or more
Records
in the
Recordset
have been changed.
The operations that can trigger this event would be either:
The first call to the
AddNew, CancelBatch, CancelUpdate, Delete, Update,
or the
UpdateBatch
methods,
The first and all subsequent calls to those same six methods.
If a filter has been used or is in place, you will only see the
Records
that are visible through the filter. Further, you cannot change the filter during this event.
In contrast, the
RecordChangeComplete
event can be fired after any changes in the values for one or more
Record
objects have been completed.
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.
The
adReason
parameter is one of seven of the
EventReasonEnum
constants that describe what pending operation caused this event to fire. Note that there is a total of fifteen of these constants, but only the following seven can actually be used by this parameter.
EventReasonEnum Constants
Constant
Value
Description
adRsnAddNew
1
A record is added
adRsnDelete
2
A record is deleted
adRsnFirstChange
11
Any operation that makes the first change to a record
adRsnUndoAddNew
5
An add is cancelled
adRsnUndoDelete
6
A delete is cancelled
adRsnUndoUpdate
4
An update is cancelled
adRsnUpdate
3
A record is updated
The
cRecord
parameter is a long value that is the number of the records that were changed.
The
adStatus
parameter is one of the
EventStatusEnum
constants that describes the current status of the event. If the action that triggered this event was successful, then the agrument will be set to
adStatusOK
. If the pending action cannot be cancelled, it will be set to
adStatusCantDeny
.
EventStatusEnum Constants
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
The
pRecordset
parameter is the
Recordset
object to which this event applies.
Code (Visual Basic):
' 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_
WillChangeRecord
(adReason As ADODB.EventReasonEnum, _
cRecord As Long, _
adStatus As ADODB.EventStatusEnum, _
ByVal pRecordset As ADODB.Recordset )
' place any code you desire here, for example
Print cRecord & " records will be modified"
End Sub
Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information