Save main form record with no data

G

Guest

I have a main form with 4 subforms. The mainform has only one data field (and
an underlying key field). This data field is often left empty causing the
mainform not to be saved. The data in the subforms is put in the tables, but
these records can't be displayed again on the form.

Is there a simple fix, or do I have a design problem? I have tried several
things unsuccessfully. Thanks for any help or advice.

Carol
 
A

Allen Browne

You have a main table (bound to the main form), with 4 related tables (bound
to your subforms). These related tables have a foriegn key field, i.e. a
field that relates to the main table's primary key field. The entries in the
related tables will have a Null value in the foreign key field. Access
(correctly) permits that, even if you have created a relationship and
enforced referential integrity.

The records that have the null foreign key do not ever show up in the
subform again, because there is no main form record they relate to. If you
intend to have related table records with a null foreign key, you could
create another form to show them. The RecordSource for the form would be a
query with Is Null in the Criteria row under the foreign key.

If you do not intend these orphaned records, open the related tables in
design view, select the foriegn key field, and set the Required property to
Yes (lower pane).

If you want to create a main form record, you have to assign something to a
field. Perhaps you could add another field so that the user has to enter
something, e.g. entry date. Alternatively, you could add a command button
that assigns the Null value to the data field and saves the record, so you
have a record to relate the subform record to:
Me.[MyField] = Null
Me.Dirty = False
 

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