A simple example of the use of transaction processing

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello, i was wondering if anybody could give me a simple example of the use
of transaction processing.
Thank you :)
 
emerb said:
Hello, i was wondering if anybody could give me a simple example of the use
of transaction processing.
Thank you :)

I assume that you are talking about Jet/DAO. Here it is:

Dim ws As DAO.Workspace
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim lngErr As Long

Set ws = DBEngine.Workspaces(0)
Set db = CurrentDb

Set qdf = db.CreateQueryDef("", "Insert into tblX " & _
" Select * From tblY;")

ws.BeginTrans
On Error Resume Next
qdf.Execute dbFailOnError
lngErr = err.Number
On Error GoTo 0
If lngErr = 0 Then
ws.CommitTrans
Else
ws.Rollback
End If

HTH
Matthias Kläy
 
Back
Top