Results 1 to 5 of 5

Thread: mySQL (A2K3)

  1. #1
    5 Star Lounger
    Join Date
    Feb 2001
    Location
    Louisville, Kentucky, USA
    Posts
    605
    Thanks
    0
    Thanked 0 Times in 0 Posts

    mySQL (A2K3)

    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:

    <hr>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)<hr>

    Can someone please help me? Thanks.
    Roberta Price <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: mySQL (A2K3)

    Try

    mySQL = "SELECT EmailAddy FROM tEmail WHERE tEmail.Send = True"

    (I removed the * from the SQL)

  3. #3
    5 Star Lounger
    Join Date
    Feb 2001
    Location
    Louisville, Kentucky, USA
    Posts
    605
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: mySQL (A2K3)

    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.

    <hr>Run-Time error 2342

    a RunSQL action requires an argument consisting on an SQL statement<hr>
    Roberta Price <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

  4. #4
    5 Star Lounger
    Join Date
    Feb 2001
    Location
    Louisville, Kentucky, USA
    Posts
    605
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: mySQL (A2K3)

    Hans,

    I believe I've resolved it. See below:

    <hr> 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)<hr>

    Thanks for the assistance.
    Roberta Price <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: mySQL (A2K3)

    There was no mention of RunSQL in your first post in this thread. However, the problem appears to have been solved. <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

Posting Permissions

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