Delete Records based on Data in separate table

GlennG

Board Regular
Joined
May 20, 2002
Messages
80
Hello,

I receive a listing of sales results from Marketing which I import into Access. There are many closed stores in the file I import and would like to remove them. All the closed stores are listed in a separate table. This is what I tried but to no avail..... Can someone help me ? Is this feasible ? :oops:
Thanks for your help...... :pray:

mYString = "DELETE * FROM INP_STORES " & _
"WHERE (INP_STORES.STORES = STORES_CLOSED.STORES)"
dbs.Execute mYSTRING

Sales figures are listed in a table called INP_STORES
Closed strores are listed in table called STORES_CLOSED
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Why do you want to remove them?

Can't you just use criteria in queries to exclude them?

Also why have a seperate table for closed stores?

You could add a Yes/No field to the main table that indicates whether a store is open/closed.
 
Upvote 0
Thanks for the reply,

I'm new to Access and am not too sure how to go about it. Besides, given that I'm working in a process that's already in place, I don't want to get too involved in changing this or that....
 
Upvote 0
Hi,

try this SQL-Statement, it also should work on other Databases like DB2.

mYString = "DELETE a.* FROM INP_STORES as a " & _
"WHERE exists (SELECT distinct stores from stores_closed as b " & _
"WHERE a.stores=b.stores);"
 
Upvote 0

Forum statistics

Threads
1,221,832
Messages
6,162,255
Members
451,757
Latest member
iours

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top