Deleteobject and TransferDatabase

T

toomanyjoes

I'm running into a problem with a simple macro. I have a database that
weekly refreshes some of its data from a table in another database. I
use a macro to delete the table in Database1 and then transfer the new
table over from Database2. The problem is that I sometimes click the
button accidentally when I'm not on the office network so the
DeleteObject function works but then I recieve an error trying to
TransferDatabase because the program cannot find the table I'm
transferring. So I'm stuck trying to work at home with no way to
restore that deleted table and I have to go all the way back to the
office. To fix this problem I simple want to check before I delete the
table. I want to use a condition to check to see if Database2 exists
before deleting the table from Database1.

If anyone knows hoe to write a condition to do this or has any other
helpful suggestions I'd appreciate it.

Thanks,
Joe Elizondo
 
K

Ken Snell [MVP]

You could put a Condition expression in the macro on the first step (make
that first step a "StopMacro" action).

The condition expression would be something like this:
Dir("C:\PathToDatabase\Database2.mdb")=""

This uses the Dir function to see if the database is located at the path
specified. If not, the Dir function returns an empty string ("").
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top