A Transaction is a series of SQL statements placed one below another. To maintain the integrity of transaction all the SQL statements must succeed together or none of the SQL statements must succeed. If the transaction fails all the changes made on the tables are fail.
Dim myConnection As ADODB.Connection
Dim myRecordset As ADODB.Recordset
Set myConnection = New ADODB.Connection
Set myRecordset = New ADODB.Recordset
myConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.3.51;Data Source=c:\BegDB\Biblio.mdb"
'—Open the connection --
'Determine if we conected.
If myConnection.State = adStateOpen Then
myRecordset.Open "SELECT * FROM TITLES", myConnection, _
adOpenDynamic, adLockOptimistic, adCmdTable
MsgBox "The connection could not be made."
'—just to be sure --
On Error GoTo transError
'—here is the top of the transaction sandwich --
While Not myRecordset.EOF
mcounter = mcounter + 1
myRecordset!Title = myRecordset!Title & "" 'so we don't really change it
'—if we got here ok, then everything is written at once