Rollback Transaction - question for Michel Walsh

  • Thread starter Thread starter Newcomer
  • Start date Start date
N

Newcomer

I saw the thread started on 19 Feb 2003 which contained the following from
Michel Walsh ([email protected])

If I use Northwind, form Orders.

- In the declaration section, add
Private wk As Workspace
Private dblocal As Database
Private rs As DAO.Recordset


- In the form open event, add
Set wk = DBEngine.CreateWorkspace("thisOne", "admin", vbNullString)
Set dblocal = wk.OpenDatabase(CurrentDb.Name)
Set rs = dblocal.OpenRecordset(Me.RecordSource, dbOpenDynaset)
Set Me.Recordset = rs
wk.BeginTrans ' start the transaction


- In the form close event, close (set to nothing) each of the local
variables
Set rs = Nothing
Set dblocal = Nothing
Set wk = Nothing


- In the main form, add a button, change its caption to RollBack, and, under
its click event:
wk.Rollback
DoCmd.Close acForm, Me.Name


- Switch in standard view. Add XYZ at the end of "Ship To" for the first
record (Alfreds Futterkiste). Go to record two, change the ship to from the
actual "Alfreds Futterkiste" to "Alfreds Futterkiste INC". Go back to the
first record, observe that the XYZ is indeed saved, since you can see it. Go
to the second record, same observation. Click the RollBack button, re-open
the form, observe that all the modifications have been roll-back (undone).



I have tried this. It rolls back changes to records on the Order form but
it does not, however, roll back changes to records on the Orders Subform.
Is it possible to have a transaction which embraces the subform also?
 
Hi,



The key point is to open a recordset on a non default database object
and to set that recordset as recordset of the form/subform you are using.
So, in theory, if you do similar code for the subform, that should allow you
to have transaction over the sub-form. Sure, doing it, you cannot really
relay on the links between the main form and the subform. I think Getz and
company cover that aspect with details in their "Access 200x Developers'
Handbook", at Sybex.



Hoping it may help,
Vanderghast, Access MVP
 
Thanks for the prompt reply. I think this may be getting a little beyond me
but I will endeavour to pursue what you say.

Nigel
 
Back
Top