troubleshooting Question

Rollback transaction

Avatar of william007
william007 asked on
Visual Basic Classic
4 Comments1 Solution391 ViewsLast Modified:
I am using VB 6.0 to access Microsoft Access 2003 database using DAO.

I want to insert record into 3 tables, if One table fails, roll back all the transaction, how to do this?

Below tb001,tb002, and tb003 is recordset, But doing like this throw me error.

On Error GoTo HandleErr:
tb001.AddNew
tb001!Field1 = txtProdName

tb002.AddNew
tb002!Field1 = INITIAL

tb003.AddNew
tb003!Field1 = "abc"

tb001.Update
tb002.Update
tb003.Update

HandleErr:
tb001.CancelUpdate
tb002.CancelUpdate
tb003.CancelUpdate

So, what is the correct and easy way to do that?
P/S: I am open to all kind of solution, including change to ADO, or using the feature in Microsoft Access 2003, or anything else. Thanks.
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 4 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros