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?
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?