Results 1 to 3 of 3
  1. #1
    itm is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jun 2011
    Posts
    69

    Question Tring to delete anything with ImportErrors at the end


    Hi,
    I have aprocess that runs, but wi6th errors. I know wqht the errors are and they do not matter. However, they do not build up, I would like to get rid of them. so I am using the following:
    DoCmd.DeleteObject acTable, "dbo_APVEN$_ImportErrors"
    However, The problem is that they can be in different forms. Like one time they can be "dbo_APVEN$_ImportErrors" na dother times something else like "dbo_Vendor_ImportErrors".
    So if there is a way that I can look for anythign that had "ImportErrors" in it I could delete only thouse; but do not think you can use Like here in any way?
    Also I ma using Access 2007.
    Any thoughts on this would be greate.
    Thank you
    ITM

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,600
    Might have to loop through Tables collection to locate tables with string 'ImportErrors' in name.
    Check this thread http://forums.devarticles.com/micros...code-3821.html
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    Here's the code I would use (the code that is referenced in that link is good if there is only one but if you have more than one, it can miss some of them because when you delete one, the collection indices change and your For Each will bypass some). So here you move backwards through the collection and therefore don't miss any.

    Code:
        Dim z As Integer
        Dim db As DAO.Database
        
        Set db = CurrentDb
        For z = db.TableDefs.Count-1 To 0 Step -1
            If InStr(1, db.TableDefs(z).Name, "ImportError") > 0 Then
                DoCmd.DeleteObject acTable, db.TableDefs(z).Name
            End If
        Next z

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

Similar Threads

  1. Replies: 2
    Last Post: 01-24-2012, 02:16 PM
  2. Trying to Delete record using delete query
    By MooseOTL in forum Access
    Replies: 13
    Last Post: 10-04-2011, 02:30 AM
  3. Macro to delete ImportErrors tables
    By lmnnt in forum Programming
    Replies: 16
    Last Post: 06-22-2011, 03:15 PM
  4. Replies: 11
    Last Post: 03-30-2011, 01:08 PM
  5. Insert & then Delete
    By surajparmar in forum Queries
    Replies: 2
    Last Post: 08-10-2010, 06:32 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