Results 1 to 4 of 4
  1. #1
    bcurrey is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2011
    Posts
    9

    Deleting error tables

    I'm using Access 2007. Most of the times when I import a file at my company, I get an error message because the item description is too long and it creates a table. I found the topic below on how to delete the error tables in a macro, however I can't get it to work. Here's my code:



    Code:
    Application.DisplayAlerts = False
    
    Function DeleteImportErrTables()
    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
    End Function

    The error that I get says "Error Number 2950. Condition True, Arguments: DeleteImportErrTables()"

    Any ideas on how to fix this? Thanks!


    Prior Topic:

    https://www.accessforums.net/program...les-14474.html

  2. #2
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    First off, you need to remove the Application.DisplayAlerts = False from the location you have it in. It is

    1. For Excel, not Access and
    2. would need to be INSIDE a procedure and not outside of it.

    Also, how are you calling this function? It would appear you are using a macro, so you should post how you are calling that function from that macro.
    Last edited by boblarson; 08-22-2011 at 02:15 PM. Reason: add info

  3. #3
    bcurrey is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2011
    Posts
    9
    I'm a bit new at this, but I went to the "Data tools" tab on the ribbon. Clicked on Visual Basic, and then chose New - Module. I then copy and pasted the code above to the blank sheet.

    Then went to Macro, and chose "RUN CODE" and told it the function name was DeleteImportErrTables ().

    Does that help?

  4. #4
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    Quote Originally Posted by bcurrey View Post
    I'm a bit new at this, but I went to the "Data tools" tab on the ribbon. Clicked on Visual Basic, and then chose New - Module. I then copy and pasted the code above to the blank sheet.

    Then went to Macro, and chose "RUN CODE" and told it the function name was DeleteImportErrTables ().

    Does that help?
    Take out the Application.DisplayAlerts = False part.

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

Similar Threads

  1. Deleting Tables With Wildcard?
    By orcinus in forum Programming
    Replies: 2
    Last Post: 06-20-2011, 10:48 AM
  2. Error: Could not delete from specified tables
    By kaledev in forum Queries
    Replies: 1
    Last Post: 03-03-2011, 02:07 PM
  3. Replies: 11
    Last Post: 12-14-2010, 01:25 PM
  4. error between two tables
    By platinumlofts in forum Access
    Replies: 1
    Last Post: 03-23-2010, 09:13 AM
  5. Error when deleting a record
    By access in forum Forms
    Replies: 5
    Last Post: 06-15-2009, 12:33 PM

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