ADO

Filtering with a Constant

The following constants are available for filtering Recordsets.

Constant Description
adFilterAffectedRecords
Filters for viewing only records effected by the last Delete, Resync, UpdateBatch, or CancelBatch call.
adFilterConflictingRecords Filters for viewing the records that failed the last batch update.
adFilterFetchedRecords Filters for viewing the records in the current cache—that is, the results of the last call to retrieve records from the database.
adFilterNone Removes the current filter and restores all records for viewing.
adFilterPendingRecords Filters for viewing only records that have changed but have not yet been sent to the server. Applicable only for batch update mode.

The filter constants make it easier to resolve individual record conflicts during batch update mode by allowing you to view, for example, only those records that were effected during the last UpdateBatch method call, as shown in the following example:

'BeginDeleteGroup
    'add some bogus records
    With objRs1
        For i = 0 To 8
            .AddNew
            .Fields("CompanyName") = "Shipper Number " & i + 1
            .Fields("Phone") = "(425) 555-000" & (i + 1)
            .Update
        Next i
        
    're-connect & update
        .ActiveConnection = GetNewConnection
        .UpdateBatch
        
    'filter on newly added records
        .Filter = adFilterAffectedRecords
        Debug.Print "Deleting the " & .RecordCount & _
                    " records you just added."
        
    'delete the newly added bogus records
        .Delete adAffectGroup
        .Filter = adFilterNone
        Debug.Print .RecordCount & " records remain."
        
        .Close
    End With
'EndDeleteGroup