Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Macros / July 2005

Tip: Looking for answers? Try searching our database.

Deleting a table if it exists, if not don't delete

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
AZ Analog - 28 Jul 2005 18:35 GMT
Good day,
I'm trying to figure out how I can create a macro condition for a delete
command within an Access Macro.  I want to delete a table if it exists, but
not attempt to delete the table if it doesn't exist...and therefore escape
any error messages and halting the macro.  I've tried messing around with a
few combinations of Dcount as a macro condition, but I can't seem to get it
to work properly.  Would someone mind giving me a little push in the right
direction?  Thank you much!
Steve Schapel - 28 Jul 2005 19:02 GMT
AZ,

This is not possible with a macro... not in the way you are trying
anyway.  The only way around this that I can think of is to set up a
Make-Table Query to create a table with the name of the table you are
trying to delete.  Use an OpenQuery action in your macro to run the
Make-Table before the DeleteObject action.  If the table doesn't already
exist, it will now, so the DeleteObject will proceed without error.  If
it does already exist, the Make-Table will overwrite the existing, but
that doesn't matter since you are trashing it anyway.  You will also
probably want to put a SetWarnings/No action before the OpenQuery, to
suppress the display of the action query confirmation message.

Signature

Steve Schapel, Microsoft Access MVP

> Good day,
> I'm trying to figure out how I can create a macro condition for a delete
[quoted text clipped - 4 lines]
> to work properly.  Would someone mind giving me a little push in the right
> direction?  Thank you much!
AZ Analog - 28 Jul 2005 19:52 GMT
Ahhh yes, that makes complete sense...nice improvisation.  Thank you for the
help.

> AZ,
>
[quoted text clipped - 17 lines]
> > to work properly.  Would someone mind giving me a little push in the right
> > direction?  Thank you much!
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.