Email endless loop

J

janetb

I need to send an email to each person matching an id in a db (right now I'm
sending to myself as a test) upon the click of a button, but it keeps making
an endless loop. (myID is variable from earlier in the code and is working
correctly) I should only be getting 3 emails. When I execute the exact query
below separately - it only pulls up three records. Can anyone point out what
I'm screwing up?

Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strTo As String
Dim strMsg As String
Dim strCC As String
Dim strSubject As String
strCC = ""
strTo = "(e-mail address removed)"
strSubject = "Videoconferencing Participation Request " & myID

On Error Resume Next
Set db = CurrentDb()
Set rs = db.OpenRecordset("select p.email as email, e.eventTitle,
e.startDate, t.partID, e.eid from (dbo_tblParticipant t LEFT JOIN
dbo_xTblPerson p ON t.pid = p.pid) LEFT JOIN dbo_tblEvent e ON t.eid = e.eid
where t.eid=13")
Do While Not rs.EOF
strMsg = "You have been invited to participate in a videoconference. Please
go to the following page link and respond. <a
href=http://www.server.net/telehealthNet/admin/participantConfirmation.aspx?upd=0&eid="
& rs("e.eid") & "&partID=" & rs("t.partID") & ">Click Here</a> " & rs("email")
DoCmd.SendObject acSendNoObject, , , strTo, strCC, , strSubject, strMsg, True
strMsg = ""
rs.MoveNext
Loop
 
M

Mark A. Sam

Hello

This is a just something to try, change,

Do While Not rs.EOF
to
Do Until rs.EOF

God Bless,

Mark A. Sam
 
J

janetb

Mark,
Thanks for the reply, but the same thing. An endless loop. I tried
deleting all records from the table except for 3 to see if it wasn't
recognizing the query, or it was an endless loop - but it's definitely an
endless loop.

Any other ideas?

Janet
 
M

Mark A. Sam

Janet,

Remove On Error Resume Next and put some error checking... like

On Error GoTo Err_Section


YOUR CODE

Exit_Section:
Exit Sub

Err_Section:
MsgBox "Error & " Err & ": " & Err.Description
Resume Exit_Section
 
J

janetb

Mark,
Thanks for the tip. I had Error3622:Youmust use the dbSeeChanges option
with OpenRocordset when accessing a sql server table that has an identity
column. Added the option, and now everything is ducky. Thanks loads.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top