• Delete table if exist

    Author
    Topic
    #471608

    I need to find out if a or multiple tables exist (ImportError, ImportError1 etc) and if they do, delete them.
    I cannot seem to find any simple code to do so.
    Help!!

    Thanks,

    itconc

    Viewing 1 reply thread
    Author
    Replies
    • #1243976

      Something like this should be able to clear tabledefs with ImportErrors in the Title

      Code:
      Function ClearImportErrors()
      
      Dim tdf As DAO.TableDef, strName As String
      
      'Loop Tables and IF ImportErrors in Name then Delete
      
      For Each tdf In CurrentDb.TableDefs
          If InStr(1, tdf.Name, "ImportErrors")  0 Then
              strName = tdf.Name
              CurrentDb.TableDefs.Delete strName
          End If
      Next
      
      MsgBox "Import Error TabeDefs Deleted", vbExclamation
      
      End Function
      
    • #1243987

      Thanks, will try asap.
      I appreciate your help.

      itconc

    Viewing 1 reply thread
    Reply To: Delete table if exist

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: