|
Subject:
|
Main/Subform linkage
|
|
Posted By:
|
Ben009
|
Post Date:
|
4/5/2006 3:31:02 AM
|
Hi all,
Probably a simple problem, but thus far I've not been able to solve it.
I have a main form with a sub form; the subform is linked to the main form by an automaticly generated number as the subforms PK.
I can view and edit data perfectly, however when I try and add a new record to the sub form I get a message telling me that the field CAD_ID (subforms pk) is read only. Thus is will add a record to the sub form, but not link it back to the main form.
I'm wondering if the auto generated number is causing a problem somehow?
I'd be most gratefll for any ideas!
Cheers,
Ben.
|
|
Reply By:
|
mmcdonal
|
Reply Date:
|
4/5/2006 7:12:03 AM
|
It might be me, but it sounds like you have the association backwards. Shouldn't you link the subform to the main form based on the main form's PK, not the subform's PK. It should be the subform's FK to the main form's PK.
HTH
mmcdonal
|
|
Reply By:
|
kindler
|
Reply Date:
|
4/5/2006 11:28:48 AM
|
I'm not sure if that's it mmcdonal. If there's a 1:1 relationship, then using the autonumber as the PK for the subform data and having it a FK in the main form data would work fine.
Ben, are you trying to enter new data by overwriting the data in the subform, or by advancing to a blank record (>* button) and adding it there? The problem with using the autonumber as the FK in the main form's data means you can only link 1 subform entry to a given main form entry. If you need more than 1 subform entry to a main form entry, you'll need to pick a different FK for the main form's data.
|
|
Reply By:
|
mmcdonal
|
Reply Date:
|
4/5/2006 11:33:24 AM
|
There is rarely a 1:1 relationship. It is almost always 1:Many, so changing the parent and child fields to the standard (PK on parent) would resolve this problem, without more information.
mmcdonal
|
|
Reply By:
|
kindler
|
Reply Date:
|
4/5/2006 1:07:46 PM
|
True, but it also works for a many:1 (i.e. a part browsing form, with the vendor info in a subform).
|