Adding a record to a subform

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

This has been bugging me for ages and it's probably right in front of me.

Form Header:
A series of unbound controls, some of which source info from tblPersonInfo

Form Detail:
A subform that displays records of tblHolidays

I initially tried a query that links all the info from both tblPerson and
tblHolidays but upon creating a new 'holiday' record, it also created a new
'person' record instead of just refering to it.

Basically, when you click cmdAdd, i want to go to the sub form, create a new
record then transfer the info from the unbound header controls into the
various fields of the new record.

I should really know this but its driving me nuts.

Thanks for any help you might be able to give.
 
Do you have a one-to-many relationship between tblPerson and tblHolidays?
And do you have a control (perhaps a combo box) on the main form that
contains the primary key for the current person?

If so, what you need to do is set the LinkMasterFields and LinkChildFields
properties of your subform control as follows:
LinkMasterFields: name of the "PersonID" control on your main form
LinkChildFields: name of the related foreign key field containing the
"PersonID" in tblHolidays

This will ensure that any new record added to your subform will have the
correct PersonID, which will automatically link it to the correct tblPerson
record.
 
Back
Top