Saving subform on Main form at the time of record save

  • Thread starter Pete Moore via AccessMonster.com
  • Start date
P

Pete Moore via AccessMonster.com

I have a subform on my main form. The main form header is tblHeader and the
subform is in the detail area using tblMain. After update of the combo box
on my main form, the subform changes based on the value in the combo box.
This works just fine, but when I save the record, the main form fields are
only being saved NOT the subform fields.

How do I save the subform fields when I save the record??

Oh, I'm using a query to link the tblHeader and the tblMain for the subform
fields which should save records from both the tables.

Thanks,
Pete
 
A

Allen Browne

The related record(s) in the subform cannot exist before or at the time the
record in the main form is saved.

Open the Relationshps window (Tools menu.) If you have set this up
correctly, you will have created a one-to-many relationship between
tblHeader and tblMain. tblHeader (the main form's table) will be the primary
table in the relationship. tblMain (the subform's table) will be the related
table, so it will have a field that relates to the primary key of
tblHeeader. This relationship will have the Referential Integrity box
checked.

If that is all set up correctly, then you must enter the main form record
*before* you can create the subform records. There can be no related records
in the subform until there is a record in the main form to relate them to.
To prevent accidental records in the related table, I suggest you open
tblMain in design view, select the foreign key field, and set its Required
property (lower pane in table design) to Yes.

I'm concerned about the combo box on the main form. If you are tying the
related record to the main form record on a combo, then the primary field is
probably not unique, which sounds like part of the problem.
 

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