Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2008

    Unhappy Unanswered: Problem with code...


    I need some expert help here!

    I have a button on a form, which, once clicked goes to the query "open Issues", and I want it to send an email for all the open records.

    The code below sends the email, etc., but it only finds the first record, and populates the email continuously with the same data?

    I bet this is something really easy for someone to point out the error of my ways, so I am looking for that person!

    Any help and advise is greatfully appreciated.


    Private Sub EmailButton_Click()

    Dim eSub, eText As Variant
    Dim rst As dao.Recordset

    Set rst = CurrentDb.OpenRecordset("open issues")

    Do While Not rst.EOF
    eSub = "E Notification - Number: " & Me.ID

    msgMessage = "We have been notified by the local authority regarding the following incident:" & [SiteID] & " at " & Me.Date & " " & Me.Time

    emailaddress = ""
    eText = msgMessage

    DoCmd.SendObject , , , emailaddress, , , eSub, eText, False

    End Sub

  2. #2
    Join Date
    Jul 2004
    South Dakota
    You open up the recordset but then never use the data from it.

    Instead of using Me.ID, Me.Date, need to use rst!ID, rst!Date, etc.

    Hope that helps.


Posting Permissions

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