DAO Transactions and subs

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
 
A

Allen Browne

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
 
D

Diarmuid

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top