PDA

View Full Version : Execute Insert Query and get the key



vincent
02-08-2008, 11:51 AM
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

vincent
02-08-2008, 03:27 PM
Ok what about If I try something like that:



Dim OrderNumber

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