Update 2 tables with one field?

J

jlan

I have 3 tables, employee, timesheet and order. timesheet is linked by
the employeeid field to employee table and by masternmbr to order
table. The timesheet subform is the main data entry form where the
employeeid is fed automatically once the employee name is selected from
the employee main form. timesheet subform collects masternmber as input
by a text field by whomever is entering the data. I would like the
master number field input to the timsheet table (via the timsheet form)
to simultaneously enter that master number into the order table (which
has no input form). Is this possible?
Thanks :)
 
P

Pieter Wijnen

Do it in the afterInsert event of the subform

Sub Form_AfterInsert()
CurrentDb.Execute "INSERT INTO ORDERTABLE (masternmbr) VALUES(" &
Me.masternmbr.Value & ")"
End Sub

HTH

Pieter

jlan said:
I have 3 tables, employee, timesheet and order. timesheet is linked by
the employeeid field to employee table and by masternmbr to order
table. The timesheet subform is the main data entry form where the
employeeid is fed automatically once the employee name is selected from
the employee main form. timesheet subform collects masternmber as input
by a text field by whomever is entering the data. I would like the
master number field input to the timsheet table (via the timsheet form)
to simultaneously enter that master number into the order table (which
has no input form). Is this possible?
Thanks :)



--
 
P

Pieter Wijnen

if it's a textfield you have to add quotes - or maybe move it to the
before_insert event
Also Add dbFailOnError to get an error msg
ie
CurrentDb.Execute "INSERT INTO ORDERTABLE (masternmbr) VALUES( '" &
Me.masternmbr.Value & "' )", dbFailOnError

Haven't got access around at the moment

HTH
Pieter

jlan said:
I just can't seem to get that to work? Is there anything I should
change?



--
 

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