Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Writing info to TWO tables at the same time.

0 views
Skip to first unread message

HMJessen

unread,
Jul 24, 2008, 9:19:02 AM7/24/08
to
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.

Allen Browne

unread,
Jul 24, 2008, 9:31:36 AM7/24/08
to
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

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"HMJessen" <HMJe...@discussions.microsoft.com> wrote in message
news:BF2E2DAB-0831-438B...@microsoft.com...

HMJessen

unread,
Jul 24, 2008, 10:07:01 AM7/24/08
to
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.

0 new messages