Consulting

Results 1 to 2 of 2

Thread: Execute Insert Query and get the key

  1. #1
    VBAX Newbie
    Joined
    Feb 2008
    Posts
    2
    Location

    Question Execute Insert Query and get the key

    So,

    I created a SQL query in access that Insert a row in a table.
    In my vba code, I want to run this query and get the primary key for the new row added.

    I tried:
    DoCmd.OpenQuery "QueryExportOrdersTable"
    But I want to know how can I get the key?

    Thanks

  2. #2
    VBAX Newbie
    Joined
    Feb 2008
    Posts
    2
    Location
    Ok what about If I try something like that:

        Dim OrderNumber
        
        INSERT INTO Orders (Name )
        OUTPUT Orders.OrderNumber INTO OrderNumber
        Values('testname')

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •