Delete command on Form/subform

G

Guest

What I am trying to accomplish is this:

When a user creates a new invoice on frminvoice, then enters the order
details in the frminvoicedetails, but then wants to delete the invoice. I
added a delete command button but it only deletes the record associated with
the main form.

How do I delete the information within the subform that is assocated with
that particular invoiceid that has been deleted?

Any suggestions?

Thanks,

Brook
 
R

Rick B

One way is to turn on cascading deletes in your relationship window. When
on, any time you delete a main record, all the associated records would be
deleted.
 
V

Van T. Dinh

You can set Referential Integrity with Cascade Delete Related Records and
the related Child Records will be deleted automatically when the Parent
Record is deleted. However, this is rather dangerous as it is too easy to
delete Child Records in you accidentally delete the Parent Record.

The other way is to use code to run a Delete Query / SQL String to delete
the related Child Records first before deleting the Parent Record.

Check Access VB Help on RunSQL or OpenQuery Method.
 
G

Guest

Thank you...

That worked great..

Brook

Rick B said:
One way is to turn on cascading deletes in your relationship window. When
on, any time you delete a main record, all the associated records would be
deleted.
 

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