My guess is that you haven't saved the parent record when you open the
child form. If you used the more conventional main form/subform
arrangement Access would see to this for you, but as it is you have to
make sure the parent record is saved before you can add any records
related to it. In the code for the button, before you call the
DoCmd.OpenForm method to open the child form, put this line of code:
Me.Dirty = False
That will save the parent record.
By the way, I wouldn't "sum up the item totals and write it to the
parent record." That's redundant information. Instead, I'd use a
calculated control on the main form that uses DSum to display the
total of the related invoice items. You might have to recalc the main
form when you close the child form; you could do that with a line
like:
Forms!frmInvoice.Recalc
in the Close event of the child form.
--
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)
Quote:
> I have a form that I use to enter invoices. That form has
> a button that brings up a child form to add Invoice detail
> items. When you exit the child form, it sums up the item
> totals and writes it to the parent record. This all
> worked fine until I implemented relational integrity so
> cascading deletes would work. Now the child form always
> complains that there is no record in the parent form.
> How do I implement this with relational integrity turned
> on?