DAO Transactions and subs

  • Thread starter Thread starter Diarmuid
  • Start date Start date
D

Diarmuid

I want to set up a DAO transaction, which I have in my main procedure.
But if I call sub procedures, any updates there won't be included in the
transaction. I'd like to include the sub procedures, as I may need to
rollback the whole lot.
And advice on how I would do this?
Thanks
Diarmuid
 
Pass the objects from the main proc to the sub.

Example:

Function MyMain()
...
ws.BeginTrans
set db = ws(0)
Set rs = db.OpenRecordset("MyTable")
Call MySub(rs)
ws.Rollback
End Function

Function MySub(rs As DAO.Recordset)
rs.AddNew 'Any change that the main proc will roll back.
rs.SomeField = "hello world"
rs.Update
End Function
 
Ok, thanks. In my case, theres recordsets in the sub that aren't necessary
in the main. I'll just open them in the main.

Diarmuid
 
Back
Top