How can I use a macro to delete Microsoft Access tables with relationships?

I need to provide a limited view of a database to a few individuals, with only a few tables and queries. My thought was to create a new database, and import the relevant tables into it. I created a macro that runs an import specification, and it works fine.

The problem is refreshing the tables. I want to run a scheduled task for this and, as you probably know, this raises several issues. First, repeatedly running the macro creates multiple copies of the tables and queries.  And deleting the tables before re-running the import routine fails because of relationships between the tables. I don't care about losing the relationships. I want to delete everything and then import the tables again, in just one shot.

I should also say that I've been using Access for a long time, but I don't do anything extremely complicated with it. So my experience is extensive but my skill level is moderate. I use macros because they're easy to use and work for my simple tasks. I don't have much experience with VBA in Access.

Thanks for your help.
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.

Fabrice LambertFabrice LambertCommented:
Instead of "refreshing tables", what about running 2 queries:
One that will delete existing data.
One that will insert new data.
davewalter1Author Commented:
I thought about doing that, and I will if I have to, but I don't want to include those queries in the new database.
Copying the data leaves you in jeopardy of the copy being out of date.  Why would you not just link to the permanent tables?  Also if the forms/reports etc are copies of what already exists in the production database, you have now created a maintenance problem because you (or your successor) have two sets of objects to update.  I would rethink this process.

However, if your heart is set on your present course of action, just remove the RI.  The satellite data should never be updated, so RI isn't necessary.
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

davewalter1Author Commented:
I'm not concerned about currency, because the data in these tables don't change very frequently, and I'll rebuild every day. There's no maintenance issue, because no one will be writing to this database. I can't remove referential integrity without directly interacting with the database, and I don't want to do that. All I want to do is import a few tables and queries, delete them, import them again, and do this once a day.
You are building the RI somehow.  Stop building it.

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
davewalter1Author Commented:
Actually, this put me on the right track. Thanks so much! Here's what was happening: I was importing a group of tables in one shot using one import specification. Importing the tables this way retained their relationships. Because they had relationships, I couldn't delete them with a macro. If I import each table individually, they lose their relationships, and I can delete them with a macro.

Thanks again!
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

From novice to tech pro — start learning today.