ADO FetchComplete Event
The FetchComplete event is fired after all of the records have been
retrieved in an asynchronous fetch for a client-side Recordset.
An event is simply a subroutine that is automatically called 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. For example, you could notify the
user that the fetch is completed, rather than making period status
checks using the
FetchProgress event.
There are three parameters passed to this event.
Syntax
FetchComplete objErr,status,objRs
|
Parameter |
Description |
objErr |
The name of an Error object that describes the
error if status is set to adStatusErrorsOccurred, otherwise it
is not set
|
status |
An EventStatusEnum value that indicates the
status of the execution of the event
|
objRs |
The name of the Recordset object that triggered
this event
|
Example
'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_FetchComplete(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
|
EventStatusEnum Values
Constant |
Value |
Description |
adStatusOK |
1 |
The operation that caused the event was
successful |
adStatusErrorsOccurred |
2 |
The operation that caused the event failed |
adStatusCantDeny |
3 |
The operation that caused the event cannot be
cancelled |
adStatusCancel |
4 |
The operation that caused the event is
cancelled |
adStatusUnwantedEvent |
5 |
Prevents subsequent notifications before the
event method has finished executing |
|