Update 2 tables with one field?

  • Thread starter Thread starter jlan
  • Start date Start date
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 :)
 
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 :)



--
 
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?



--
 
Back
Top