Parent Child Forms Problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

I have a form with some Main Form information and with couple of sub-forms.
All required fields in the main form have default values, and most of the
time user doesn't have to change them. At the time of adding a new record if
user doesn't change any field in the main form and start adding information
in the child form, Access gives an error because of refrencial contraint on
tables and says that the parent table needs to have a corresponding record. I
understand that the status of main form doesn't change if the values are
default so it doesn't save on loosing focus. Is there any way arround this?

Rashid
 
try manually setting a value in the main form, even if it has a default
value. that should tell Access that you're trying to enter a new
record. Then save the record. Access should now have saved the record
in the main form, and allow you to add a child record.
You could do this in vba code, or you could ask the user to do this,
like unchecking and rechecking a tick box in the main form.
 
RM said:
Hi

I have a form with some Main Form information and with couple of
sub-forms. All required fields in the main form have default values,
and most of the time user doesn't have to change them. At the time of
adding a new record if user doesn't change any field in the main form
and start adding information in the child form, Access gives an error
because of refrencial contraint on tables and says that the parent
table needs to have a corresponding record. I understand that the
status of main form doesn't change if the values are default so it
doesn't save on loosing focus. Is there any way arround this?

Rashid

Either...

Have the user enter at leat one value in the main form

Hide/Disable the subforms in the current event of the main form when it lands on
a new record and provide a button that Displays/Enables them. In the code for
that button set the value of one field in the main form equal to itself. That
will dirty the main record so that a record will be created when they move focus
to a subform.

You might be able to leave the subforms visible and enabled and just do the
above in the Enter event of all of the subforms, but I have never tried that.
 
Back
Top