Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Feb 2002
    Location
    Monroe, Wisconsin
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Delete an Object (Access 97)

    I import various files from our mainframe, when I encounter an error, Access makes a table listing those errors. I would like to delete this table when it occurs. Is there a way to determine if an object exist and if it does, delete it? Thanks.

  2. #2
    Star Lounger
    Join Date
    Mar 2001
    Location
    Dudley, Midlands, England
    Posts
    55
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Delete an Object (Access 97)

    It depends on how much of a purist you are. You may find the easiest solution is to turn off error trapping (On Error Resume Next) then execute one of the following statements

    CurrentDb.TableDefs.Delete "<table names goes here>"
    or
    CurrentDb.Execute "DROP TABLE [<table name goes here>]"

    If you wanted to be a bit neater you could leave error trapping on and in your error handling section check for (and ignore) either value 3265 (for the first example) or 3376 (for the second) both of which indicate that the table wasn't found.

    Don't know if this helps you at all.

    Simon

  3. #3
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Delete an Object (Access 97)

    Hi raz

    Somebody sent this to me when I was looking for a solution to delete import error files.

    HTH

    John

    Perfor at startup

    Function DeleteImportErrors()

    Dim db As DAO.Database
    Dim tdf As TableDef
    Dim i As Integer

    Set db = CurrentDb

    For i = db.TableDefs.Count - 1 To 0 Step -1
    If db.TableDefs(i).Name Like "ImportError*" Then

    db.TableDefs.Delete db.TableDefs(i).Name

    End If
    Next

    End Function

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •