Getting AutoID From a Record In a Transaction

Posted on 2005-04-06
Last Modified: 2010-05-02
I am processing a transaction as follows:

1) Add a new record to the SALES Table which includes an AutoNum field.
2) Adding a record to the SALEDETAIL table which requires the AutoNum from the SALES table.

How do I implement this within a single transaction using the BeginTransaction and CommitTransaction function of ADO?
I tried calling them in succession but the AutoID from the SALES table is NULL. I guess it doesn't get populated until the transaction is committed.

I need to be able to roll back if there are any errors so I don't see how any other method would work. Please keep in mid also that the structure of the database cannot change. Thanks for your time!
Question by:kevman123
    LVL 14

    Accepted Solution


    Author Comment

    Wonderful! Thanks so much.
    LVL 14

    Expert Comment

    by:Shiju Sasidharan
    Thank u kevman123

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
    Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now