Writing info to TWO tables at the same time.

H

HMJessen

We have a DB where two of the tables HAVE to have the employees ID entered.
Table1 is where the personnel information is kept (Name, DOB, Address, etc.)
and Table2 is where the equipment that is issued to this person is kept.

When a new employee is hired, the main DB has a button (new employee) which
opens a small form asking for the name, team assignment and employee ID.
This infor is written to Table1, and the employee needs to be written to
Table2 also.

So far, i have not been able to get this to work.

Can anyone offer some assistance, please?

Thank You.
 
A

Allen Browne

So the small form is bound to table1 (your employee table), and you have
another table where you want to also insert one new record using the new
EmployeeID value?

Use the After Insert event procedure to execute an Append query statement
that writes the new record. This kind of thing:

Private sub Form_AfterInsert()
dim strSql As String
strSql = "INSERT INTO Table 2 ( EmployeeID ) SELECT " & _
Me.EmployeeID & " AS EmpID;"
db.Execute strSql, dbFailOnError
End Sub
 
H

HMJessen

Allen,

I think I will have to play with it a bit as it isn't working right out of
the box, but hey, that is how we all learn.

Thank you for the help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top