Transactions may suit, they allow rollback: http://msdn.microsoft.com/en-us/library/bb243155.aspx
EDIT
Here is a rough example in DAO:
Dim strSQL As String
Dim db As DAO.Database
Dim wrk As Workspace
On Error GoTo TrapError
Set db = CurrentDb
Set wrk = DBEngine.Workspaces(0)
wrk.BeginTrans
strSQL = "Update sysInfo Set InvoiceOR=False"
db.Execute strSQL, dbFailOnError
wrk.CommitTrans
Exit_Sub:
Set db = Nothing
Set wrk = Nothing
Exit Sub
TrapError:
MsgBox "Failed: " & Err.Description
wrk.Rollback
Err.Clear
Resume Exit_Sub
Here are some rough notes for ADO:
Dim cmd As ADODB.Command
Dim cn As ADODB.Connection
Set cmd = CreateObject("ADODB.Command")
Set cn = CurrentProject.Connection
cmd.CommandText = "Update sysInfo Set InvoiceOR=False"
cmd.ActiveConnection = cn
cmd.ActiveConnection.BeginTrans
cmd.Execute , , adExecuteNoRecords
If Err <> 0 Then
cmd.ActiveConnection.RollbackTrans
Else
cmd.ActiveConnection.CommitTrans
End If
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…