WillMove Event
Error Object
EVENT: Recordset::MoveComplete
MoveComplete
(adReason, pError, adStatus, pRecordset)
The
MoveComplete
event can be fired after the current position inside the
Recordset
has been changed by an operation that involves a call to the
AddNew, Move, MoveFirst, MoveLast, MoveNext, MovePrevious, Open,
or the
Requery
methods or to the
AbsolutePage, Bookmark, Filter,
or
Index
properties. This event can be triggered for both child and parent
Recordset
objects.
In contrast, the
WillMove
event can be fired before a position change occurs 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.
The
adReason
parameter is one of six 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 six can actually be used by this parameter.
EventReasonEnum Constants
Constant
Value
Description
adRsnMove
10
The record pointer has been moved in the
Recordset
adRsnMoveFirst
12
The record pointer has been moved to the first record in the
Recordset
adRsnMoveLast
15
The record pointer has been moved to the last record in the
Recordset
adRsnMoveNext
13
The record pointer has been moved to the next record in the
Recordset
adRsnMovePrevious
14
The record pointer has been moved to the previous record in the
Recordset
adRsnRequery
7
The
Recordset
has been requeried
The
pError
parameter will be set only if an error occurred and the
adStatus
is set to
adStatusErrorsOccurred
. It is an
Error
object that describes the error.
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 an error occurred, it will be set to
adStatusErrorsOccurred
.
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_
MoveComplete
( 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
Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information