Results 1 to 2 of 2
  1. #1
    Petefured is offline Novice
    Windows XP Access 2000
    Join Date
    Oct 2008
    Posts
    16

    Issue with Do

    Dear All,

    I have the following code
    Code:
    Dim dbs As DAO.Database     Dim strsql As String     Dim rs As DAO.Recordset     Set dbs = CurrentDb     strsql = "qry_emailing_id"     Set rs = CurrentDb.OpenRecordset(strsql)     Do While Not rs.EOF         CurrentDb.QueryDefs("qry_emailing").SQL = Replace(CurrentDb.QueryDefs("qry_emailingtemplate").SQL, "insert", rs!UserID)         Dim rs2 As Recordset         Set rs2 = CurrentDb.OpenRecordset("qry_emailing", dbOpenDynaset)             With rs2             Do While Not .EOF             mailbody = mailbody & !UserID & "|" & !Username & "|" & !HolidayDate & "|" & !Status & "|" & !StatusMan & "|" & !ManActionDate & vbCrLf             .MoveNext             Loop             End With             rs2.Close             Set rs2 = Nothing         DoCmd.SendObject acSendNoObject, , , rs!UserID, , , "SUBJECT", mailbody         rs.MoveNext         Loop         rs.Close         Set rs = Nothing
    The intention here is to send emails to userIDs in qry_emailing_ID and each recipient would receive the relevant record in qry_emailing



    Now if I run the code the first email is correct, first user gets his records, but in the second email everything is included, not only the records of the second userID

    Could you please advise?
    Many thanks in advance

  2. #2
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Can you reformat the posted code so it reads normally? It's very hard to follow all on one line like that.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Need help with date issue.
    By ITChevyUSSNY in forum Reports
    Replies: 13
    Last Post: 02-05-2013, 10:06 AM
  2. 'Supervisor' Issue (HELP!!)
    By vt800c in forum Forms
    Replies: 3
    Last Post: 05-10-2011, 10:35 AM
  3. Criteria Issue
    By RichardS in forum Queries
    Replies: 3
    Last Post: 09-16-2010, 09:19 PM
  4. Combobox issue
    By maluna in forum Access
    Replies: 8
    Last Post: 09-08-2010, 01:01 AM
  5. adp accessing issue
    By fillerup in forum Security
    Replies: 3
    Last Post: 03-10-2010, 09:59 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums