Check the Recordset affected : Recordset Add Update Delete « Access « VBA / Excel / Access / Word






Check the Recordset affected

 

Sub exaCreateAction2()
    Dim ws As Workspace
    Dim db As Database
    Dim qdf As QueryDef
    Dim strSQL As String
    Set ws = DBEngine(0)
    Set db = CurrentDb
    strSQL = "UPDATE BOOKS SET Price = Price*1.1 WHERE Price > 20"
    Set qdf = db.CreateQueryDef("PriceInc", strSQL)
    ws.BeginTrans
    qdf.Execute
    If qdf.RecordsAffected > 15 Then
        Debug.Print qdf.RecordsAffected
        ws.Rollback
    Else
        Debug.Print qdf.RecordsAffected
        ws.CommitTrans
    End If
    
End Sub

 








Related examples in the same category

1.Add new a row to recordset
2.Adding a New Record to a Recordset
3.Use AddNew and specify the field information
4.Use AddNew method from Recordset and two arrays to add a new row
5.Adding a New Record to a Table
6.Modifying a Record
7.Performing Batch Updates
8.Delete row for a certain criteria
9.Deleting a Record
10.Call update method from Recordset
11.Call delete method in Recordset