synchronize new record in subform to related record in form

G

Guest

When adding data to a new form and its subforms, the records' links aren't
synchronized. Both are autonumbers. I have no problem with the tables and
subtables relating. I have no trouble with existing records relating. For
example, I've entered data into a main form's text boxes and it is assigned a
unique autonumber, its "ID." I enter data into a blank record in a subform,
whether a dropped-in subform or command button pop-up, and it is assigned a
unique autonumber, its "ID." The two "IDs" do not relate. In this case they
need to be the same number but aren't. I was able to synchronize existing
records between forms with macros. How do I synchronize a record that doesn't
exist yet?
 
G

Guest

The table that contains information for the subform (call it a child table)
must have a field (called a foreign key) to match the ID of the main table.
Use a datatype of Integer in the child table.
Once you have filled in the foreign key data in all of the child table
records you can create a one-to-many relations between the tables. Set
Referential Integerity and Cascade Update.
Next in open the main form in design view and click on the menu VIEW -
Properties.
Click in the upper left corner of the subform and fill in the Master and
Child links using the main table ID (primary key) and the matching field of
the child table (foreign key).
 

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