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
|