synchronize new record in subform to related record in form

synchronize new record in subform to related record in form

Post by QmVhRnJpZW » Sun, 29 Jan 2006 09:03:27


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?
 
 
 

synchronize new record in subform to related record in form

Post by S0FSTCBERV » Sun, 29 Jan 2006 09:25:26

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).