Help with Access Transactions

snypa

Registered User.
Local time
Today, 15:59
Joined
Feb 2, 2009
Messages
29
Hi guys

I'm using the query wizard in access and I'm running the queries using DoCmd.OpenQuery and I was wondering if is possible to use transactions with such queries

Cheers in advance
 
You can't exactly issue an transaction command within query; indeed, Jet doesn't support multiple statements. Therefore, you would achieve the same effect by writing a VBA procedure to initiate the transaction, call the queries and commit if successful.

Code:
Private Sub foo()

On Error Goto Abort

DBEngine.BeginTrans
CurrentDb.Execute "MyFirstQueryName", dbFailOnError
CurrentDb.Execute "MySecondQueryName", dbFailOnError
CurrentDb.Execute "MyThirdQueryName", dbFailOnError
DBEngine.CommitTrans

Exit Sub

Abort:

DBEngine.Rollback

End Sub

HTH.
 

Users who are viewing this thread

Back
Top Bottom