A simple example of the use of transaction processing

E

emerb

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

Matthias Klaey

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top