Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 1 / March 2006

Tip: Looking for answers? Try searching our database.

Scope of transaction processing wrapper

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
rdemyan - 13 Mar 2006 08:19 GMT
I have some unbound forms that I want to use transaction wrappers on when
updating the table. My question is on the scope of what transaction
processing will do. I'm going to keep it simple with the following code:

Code:
------------------------------------------------------------------------------
--

ws.BeginTrans
bInTrans = True           

'Delete record from TableA     
rs.Delete                  

'Now update TableB
Call WriteMasterTableRecord(RecordtoDelete, ValueA, ValueB)           

'Now update some information in TableC   
Call StatusAsMaster(MasterID, ValueD)

ws.CommitTrans
bInTrans = False  
------------------------------------------------------------------------------
--

Again, the code has been simplified.

What I want to know is if the transaction wrapper for TableA also covers
TableB and TableC which are updated in other procedures. In my exit handler
there is the following:

If bInTrans = True Then
ws.Rollback
End If

So, if an error occurs, the Error_Handler is invoked and then the exit
handler. Will the Rollback statement roll back the changes to all three
tables (A, B and C) or will it only roll back Table A??
Allen Browne - 13 Mar 2006 09:04 GMT
The answer to your question depends on how you write the changes to the
other tables.

If you write the changes with something like:
   db.Execute ...
where db is the database in the ws workspace, then they will rollback.

But they will not roll back if you make the changes with (say) RunSQL, or
through another Workspace variable, since these are outside of the scope of
your transaction.

Signature

Allen Browne - Microsoft MVP.  Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

>I have some unbound forms that I want to use transaction wrappers on when
> updating the table. My question is on the scope of what transaction
[quoted text clipped - 35 lines]
> handler. Will the Rollback statement roll back the changes to all three
> tables (A, B and C) or will it only roll back Table A??
rdemyan - 13 Mar 2006 16:15 GMT
Allen:

Thank you for the response.  I'm using different DAO workspace, database and
recordset variables in the procedures that update Tables B and C.  I'm not
using db.Execute type statements, but instead rsXXX.AddNew or rsXXX.Edit and
rsXXX.Update.

Does this mean that I should pass the DAO variables that update TableA into
the procedures that update TablesB and C.  Do I just pass in the ws and db
variables and then create a new recordset based on the SQL statement that is
appropriate for each procedure to accomplish that procedure's job?

If so, I assume that these DAO variables should still be closed in the
original module that created them (i.e. where TableA is updated).

Thanks.

>The answer to your question depends on how you write the changes to the
>other tables.
[quoted text clipped - 12 lines]
>> handler. Will the Rollback statement roll back the changes to all three
>> tables (A, B and C) or will it only roll back Table A??
Allen Browne - 13 Mar 2006 17:05 GMT
Yes, that all sounds right.

Just pass the Database variable, and it will all rollback.

This article illustrates transactions:
   http://allenbrowne.com/ser-37.html
It all happens in one procedure, so it does not illustrate passing the db,
but the technique is identical, and it does explain a couple of traps.

Signature

Allen Browne - Microsoft MVP.  Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

> Allen:
>
[quoted text clipped - 34 lines]
>>> handler. Will the Rollback statement roll back the changes to all three
>>> tables (A, B and C) or will it only roll back Table A??
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.