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 / Forms Programming / December 2005

Tip: Looking for answers? Try searching our database.

Dropped table still found

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Your name - 09 Dec 2005 01:43 GMT
I drop a table, and try to re-create it later.  I get a message saying the
(dropped)table is still there.

I have tried both (obviously not at the same time):

DoCmd.RunSQL "Drop Table xxx"
DoCmd.DeleteObject acTable, "xxx"

I cannot delete the rows and re-populate because when I rebuild the table,
the number of columns varies.

It is like I need a "commit", or need to refresh a catalog or something.

Any suggestions?

Thanks in advance.
Allen Browne - 09 Dec 2005 05:38 GMT
Firstlly, uncheck the boxes under:
   Tools | Options | General | Name AutoCorrect
Explanation of why:
   http://allenbrowne.com/bug-03.html
Then compact the database to get rid of this junk:
   Tools | Database Utilities | Compact

You should now be able to DROP the table, and have Access know that is is
gone. However, if the RunSQL code fails, and you have set SetWarnings to No,
you will not receive a message if it was not deleted (e.g. because a form is
using the data at the time.) To solve that, use:
   dbEngine(0)(0).Execute "DROP TABLE xxx;", dbFailOnError

If you are dropping the table and then using a Make Table query to recreate
it again, there's a better way to do it. Instead of destroying and creating
it again, just empty it, and use an Append query (not Make Table) to
populate it. This kind of thing:

   Dim db as DAO.Database
   Dim strSql as String

   Set db = CurrentDb()
   strSql = "DELETE FROM Table1;"
   db.Execute strSql, dbFailOnError

   strSql = "INSERT INTO ...
   db.Execute strSql, dbFailOnError

   Set db = Nothing

Signature

Allen Browne - Microsoft MVP.  Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

>I drop a table, and try to re-create it later.  I get a message saying the
> (dropped)table is still there.
[quoted text clipped - 12 lines]
>
> Thanks in advance.
 
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.