Macro to empty tables

PRTP

Registered User.
Local time
Today, 12:21
Joined
May 11, 2014
Messages
16
Hi

I'm wanting a macro that will erase the contents of 12 tables (but NOT delete the tables) in one go i.e. I don't want the user to have to click 12 delete queries or have 12 delete queries visible in the Object Navigation Pane. I instead want one macro that will do it all.

In the macro actions menu, I couldn't see an option to clear contents/delete all records of a table.

So I wrote some VBA along the lines of currentdb.execute "delete * from sometable", repeating that for those 12 tables.

How can I get a shortcut in the Object Navigation Pane that you can click to run that code, just like you can run an ordinary macro with a double-click?


Thanks
 
Thanks Insane_ai

I eventually got this to work using the RunCode. One of my mistakes was I had the VBA written as a Sub instead of a Function
 
Is this for testing or is this intended for use in an production environment?
 

Users who are viewing this thread

Back
Top Bottom