Insert into multiple tables

aaronward

Board Regular
Joined
Aug 2, 2006
Messages
165
Here is my (condensed) table format:

Table: A
ID|EmpNum|AuditDate|Score

Table: B
A_ID|Item1|Item2|Item3|Item4

I am essentailly storing details of employee audits on their work. I have my first table (table A) storing the Basic information about the audit. Table B will store the individually scored item results: items 1-4. Table A has an autoincrement unique id created by access. I reference the items in table B by table A's ID. I am at a standstill upon entering the audit data, tho. I currently use two seperate sql transaction for entry; Entering Table A's data then table B's data. However, I havent a way to reference Table A's ID after entry in order to use it for table B. Any suggestions on the best method of completing this task? Thanks!
 
1) You could try using this example, this should work in Access 2000 and above.

INFO: Jet OLE DB Provider Version 4.0 Supports SELECT @@Identity

http://support.microsoft.com/kb/232144/en-us


2) You could also run a query looking for the max of the id on table A after insert.
3) Another method would be to use the parameters of tableA (EmpNum|AuditDate|Score) and return the ID

HTH,
CT
 
Last edited:
Upvote 0
This method works great, however I am unable to use it on the database project which I currently have open. Is there anyway I am able to use the suggested method within the current database? I currently execute my sql querys with 'CurrentDb.Execute strSQL' thanks!
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top