Need an If statement in a Macro for deleting tables (1 Viewer)

zip11777

New member
Local time
Today, 07:42
Joined
Jun 29, 2012
Messages
4
I have a macro that refreshes data (pulling it in form XML or Excel files).
Since I want to delete the old files first, I also have a DeleteObject for each of the old tables.

However, sometimes, the old table is not there (maybe I deleted it manually, or it was the ImportErrors table, or some other reason it is not there this week).

Can I make an If statement that says something like:

If Table xyz is present, then
DeleteObject, Table xyz, else
Skip this step in the Macro


I am using Access 2010
 

namliam

The Mailman - AWF VIP
Local time
Today, 12:42
Joined
Aug 11, 2003
Messages
11,696
Just to add for intrest sake, deleting tables over and over again causes your database to bloat (grow in size) remember to compact it

Once you are done developing dropping tables is a bad idea overall, better to delete the contents instead.
 

zip11777

New member
Local time
Today, 07:42
Joined
Jun 29, 2012
Messages
4
I will try above, but if you have better solution, I am all ears: Here is the scenario:

One of our tools sends an XML file to an FTP site nightly so that a third party can use that data in another app.

My role is to validate the data in the XML file on a daily basis, so I was looking to pull it into Access (from there I massage it a little and then export as Excel file for further analysis).

Since I could not find a way to either Link and Refresh the XML, nor does Access let me create a Saved Import spec for the XML, I was deleting the table and manually pulling in the XML again. Sometimes there are errors, sometimes not, so my Macro crashes when it doesn't see that table.
 

namliam

The Mailman - AWF VIP
Local time
Today, 12:42
Joined
Aug 11, 2003
Messages
11,696
What didnt work?

Importing XML in access can be a nightmare, I usually end up writing my own code to read the data from it since the auto-thingy creates so many orphans it isnt funny.
 

Users who are viewing this thread

Top Bottom