• mySQL (A2K3)

    Author
    Topic
    #454929

    Good Afternoon,

    I am trying to get the email address (EmailAddy) of all records from a table (tEmail) where the field “SEND” is TRUE and use the returned records as criteria for an Outlook process, w/o using a query. I have the outlook process and all is well there, what I can’t refine is the SQL syntax that returns only the records I’m looking for.

    Below is the code I’ve been trying to use and fails:

    [indent]


    Dim myDb As DAO.Database
    Dim myRs As DAO.Recordset

    Set myDb = CurrentDb()
    mySQL = “SELECT EmailAddy * FROM tEmail WHERE tEmail.Send = -1”
    Set myRs = DBEngine(0)(0).OpenRecordset(mySQL, dbOpenDynaset)


    [/indent]

    Can someone please help me? Thanks.

    Viewing 0 reply threads
    Author
    Replies
    • #1130584

      Try

      mySQL = “SELECT EmailAddy FROM tEmail WHERE tEmail.Send = True”

      (I removed the * from the SQL)

      • #1130586

        I’ve tried that several times earlier but thinking I missed something I tried your suggestion again and still I get the following error msg.

        [indent]


        Run-Time error 2342

        a RunSQL action requires an argument consisting on an SQL statement


        [/indent]

        • #1130600

          There was no mention of RunSQL in your first post in this thread. However, the problem appears to have been solved. smile

      • #1130594

        Hans,

        I believe I’ve resolved it. See below:

        [indent]


        Dim db As DAO.Database
        Dim tdf As DAO.TableDef
        Dim rst As DAO.Recordset
        Dim mySQL As String

        mySQL = “SELECT tEmail.EmailAddy ” & _
        “INTO tblTemp ” & _
        “FROM tEmail ” & _
        “WHERE Send=True;”

        DoCmd.SetWarnings False
        DoCmd.RunSQL mySQL
        DoCmd.SetWarnings True

        Set db = CurrentDb()
        Set tdf = db.TableDefs(“tblTemp”)
        Set rst = db.OpenRecordset(“tblTemp”, dbOpenTable)


        [/indent]

        Thanks for the assistance.

    Viewing 0 reply threads
    Reply To: mySQL (A2K3)

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

    Your information: