Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2010

    Unanswered: Receiving an ImportError, and sending it as an Object

    Hi all,

    Not new to Access, but very very new to VBA.

    I have a macro that imports a delimited text file, and on occasion there is a ImportError (because it contains invalid characters) and a table is created. I would like this database to recognize when this happens, and sends that Import ErrorTable as an object/email.

    Can this be done within the macro, or is this going to require VBA?

    [note] This database runs automatically using scheduler on a virtual machine, so a solution hopefully needs to be done without manual input.


  2. #2
    Join Date
    Mar 2009
    Provided Answers: 14
    After importing the file, you could use a function to test for the existence of the ImportError table and, if necessary, send it:

    <Command to import the text file>
    If TableExist("ImportError") Then
        <Command to send the ImportError table by email>
        Docmd.DeleteObject acTable, "ImportError "
    End If
    Function TableExist(ByVal TableName As String) As Boolean
        Dim dbs As DAO.Database
        Dim tdf As DAO.TableDef
        Set dbs = CurrentDb
        For Each tdf In dbs.TableDefs
            If tdf.Name = TableName Then
                TableExist = True
                Exit For
            End If
        Set dbs = Nothing
    End Function
    Have a nice day!

Posting Permissions

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