Create New Record In MainForm when Editting SubForm

Yak77

New member
Local time
Today, 15:30
Joined
Dec 16, 2010
Messages
3
I have a MainForm linked to a SubForm (1 to many relationship).

If I go to add a new record in the MainForm and begin entering data in the MainForm everything works properly (The MainForm AutoNumber PK gets generated and the corresponding SubForm FK gets set to the number that was generated).

If I go to add a new record in the MainForm and begin entering data in the SubForm, the MainForm's PK is not autogenerated.

I searched and could not find a good solution to this problem. The only thing I found was people preventing the SubForm from being edited until the MainForm was edited. Is there really no way to edit a SubForm first when creating a new record on the MainForm and have it autogenerate the MainForm ID? It seems like such a pain to require the user to first start editing the MainForm before being allowed to edit the SubForm.

Any help would be greatly appreciated.
 
The problem is that until you have entered data into at least one field of your main form, the parent record has not been generated. So if you go directly to the sub form you will create an Orphaned child record, ie. a record that is not related to any parent record.

It does not make any sense for a user to start generating a new child record without first completing some of the fields required to create a parent record :confused:
 
The way i prefer to deal with this is to set the required option for the FK to yes and then trap error 3314, telling users to input data into the required parent form field(s) first.
 

Users who are viewing this thread

Back
Top Bottom