Sometimes, you'll have a problem when you open a detail form for a brand new record. If there is a subform with child records on the detail form, your user will encounter an error if they try to create a child record before they have entered any data for the parent (master) record, as shown in Figure I-10.
This is because the parent key still has a Null key, and the child record has a required foreign key for the parent Business record. Even if the foreign parent key in the child record isn't set to Required, there will be another problem: The child record will have a null foreign parent key, making it an orphan record with no parent.
One way to prevent this error is to create an empty record before opening the Detail form. This way, the parent record already has a primary key and can accept related child records. During this preloading operation, you can specify a default name for the new record, such as "<New Business>". This gives your user a clear indicator that they have just created a new record and allows them to add child records immediately. The new record is shown in Figure I-11.
The code to preload the record is in the index form "frmBusinesses", in the Click event of ...