DAO - AddNew/Update 
Author Message
 DAO - AddNew/Update

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?



Sat, 02 Apr 2005 23:59:50 GMT  
 DAO - AddNew/Update
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?



Sun, 03 Apr 2005 00:19:17 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Help with DAO AddNew / Edit And Update in VB 4

2. DAO AddNew problem

3. Addnew 3146 in DAO

4. MultiUser Database DAO - 'Addnew'

5. Problem with DAO addnew method

6. MultiUser Database DAO - 'Addnew'

7. Porting AC'97 .addnew and .update for compatibility w/SQL 7

8. Update or CancelUpdate without Edit or AddNew

9. ado.net - addnew, edit, update, delete

10. How do I gett the value of autoincrement field after an .AddNew/.Update

11. AddNew without Update

12. AddNew/Update autonumber problem

 

 
Powered by phpBB® Forum Software