Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete record in 2 tables

Status
Not open for further replies.

mwheads

Programmer
Apr 24, 2004
38
ZA
Hi All

I would like a button to run code to prompt the user (InputBox) for a reference and then delete the record in the first table and then all records with that reference in the 2nd table.

Field - SupplierReference
tblTranactions - no duplicates (so only one to delete)
tblLedgerPosting - duplicates

I have not come right so far, any suggestions.

Regards,
 
Hi,

By far the easiest way to do do this is to set up a relationship between the two key fields in your table. Link from the table where the key is a primary key (i.e only one entry) and drag it across to the same field on the other table. When the relationship window comes up it will say it is a 1 to many relationship. Ensure the cascase delete is selected and when you delete a record from your primary table all of the other records with that ID will be deleted as well.

Hope this helps


Andrew
 
Hi Afryer

Thanks I will do that, some things are simpler than we think
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top