Results 1 to 4 of 4
  1. #1
    DaveE is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2010
    Posts
    7

    Smile TableDefs.Delete

    Hi all
    I am attempting to delete all but one table in my Access 2007 database.
    All relationships have been deleted.
    First, if I rem out the line db.TableDefs.Delete, then all the appropriate tables are displayed alphabetically.
    However, when I include db.TableDefs.Delete, the process becomes inconsistent.
    Currently only every second table is displayed and deleted, previously all but one table were deleted.
    If I run the code a second time, the remainder of the tables are deleted.

    Could it be that my Toshiba NB100 netbook is not up to the task?
    I don't have another machine with Access 2007 installed.
    I have tried to slow down execution of the code with MsgBox, and by using db.TableDefs.Refresh.



    For Each tdf In dbs.TableDefs
    If Left(tdf.Name, 4) <> "msys" And tdf.Name <> "tblUser" Then
    MsgBox "Table to delete = " & tdf.Name
    db.TableDefs.Delete tdf.Name
    'db.TableDefs.Refresh
    End If
    Next tdf

    Thanks in advance for any advice offered, I can't afford to lose any more hair.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    The key is to go backwards:

    http://support.microsoft.com/kb/210307
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    DaveE is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2010
    Posts
    7
    Thanks Paul
    Your solution works great

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    Happy to help, and welcome to the site by the way!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Delete Query
    By stan.chernov@gmail.com in forum Queries
    Replies: 3
    Last Post: 09-17-2010, 04:10 PM
  2. Delete Query
    By jgelpi16 in forum Queries
    Replies: 2
    Last Post: 09-14-2010, 12:16 PM
  3. Insert & then Delete
    By surajparmar in forum Queries
    Replies: 2
    Last Post: 08-10-2010, 06:32 AM
  4. Replies: 1
    Last Post: 07-22-2010, 05:52 PM
  5. #delete records
    By supernova122 in forum Access
    Replies: 0
    Last Post: 07-08-2009, 08:41 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums