Delete records from 2 different tables

I have 2 tables item_cat_subcat which contains ITEMNMBR, CAT_ID, and SUBCAT_ID which will contain 1 record with that ITEMNMBR  and item_attrib_attribvl which contains  ITEMNMBR, ATTRIB_ID, and ATTRBVLU_ID which could contain multiple  ITEMNMBR  values. I also have a form frmAssignedItems based on a query (See Image) that displays the records in those tables. and a delete button next to each record on the form, I want to be able to delete the records from both tables based on the ITEMNMBR  on the form with VBA.
skull52IT director Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

1. Define primary keys for all tables.
2. Create Referential Integrity using the relationships dialog.
3. Specify cascade delete on relationships where you want deletes to be propagated.

Based on the joins shown in the diagram, item_cat_subcat is the parent table to TWO child tables.  If you want the delete to work on the parent record, then Cascade Delete must be defined on both of these relationships.

Otherwise, you're on your own and will need to run separate delete queries on all tables that you want to delete from.
skull52IT director Author Commented:
Pat, the only tables that i want the records deleted are item_cat_subcat and item_attrib_attribvl
skull52IT director Author Commented:
<Otherwise, you're on your own and will need to run separate delete queries on all tables that you want to delete from.> I don't necessarily have a problem with doing that as it is only the 2 tables, so how would I do that
Acronis True Image 2019 just released!

Create a reliable backup. Make sure you always have dependable copies of your data so you can restore your entire system or individual files.

Use the QBE to build the query.  The criteria can reference the form field.  Intellisense will help you build it.

Delete * from sometable Where somefield = Forms!yourform!yourfield;

Then you can use DoCmd.OpenQuery to run each query.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
skull52IT director Author Commented:
Pat, thanks I was able to do what I wanted by creating queries as you suggested.
You're welcome.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.