trying to loop thru all the users who are set to receive a report:
I cannot figure out how to make is stop looping after the last person
Code:
On Error GoTo ErrorRPT
Dim db As Database
Dim rs As Recordset
Dim Sendto As String
Set db = CurrentDb
Set rs = db.OpenRecordset("User Name", dbOpenDynaset)
Forms![Infokeeper]![Startdate] = Me.Startdate
Forms![Infokeeper]![Enddate] = Me.Enddate
If DCount("[Receiving Report]", "User Name", "[Receiving Report] ='" & "Yes" & "'") = 0 Then
Else
With rs
.MoveFirst
.FindFirst ("[Receiving Report] ='" & "Yes" & "'")
Sendto = .Fields("Email Address")
'If DCount("[Receiving Report]", "User Name", "[Receiving Report] ='" & "Yes" & "'") = 0 Then
'GoTo Ende
'Else
'Nexte:
'.FindNext ("[Receiving Report] ='" & "Yes" & "'")
'Sendto = Sendto & "; " & .Fields("Email Address")
'If DCount("[Receiving Report]", "User Name", "[Receiving Report] ='" & "Yes" & "'") = 0 Then
'GoTo Ende
'Else
'GoTo Nexte
'End If
'End If
End With
rs.Close
End If
'Ende:
DoCmd.SendObject acSendReport, "Receiving Report", acFormatRTF, Sendto, , , "Receiving Report", "Automatically generated message from SAI Inventory Program"
DoCmd.Close
GoTo Endsubtxt
ErrorRPT:
Call ErrorRPT1
Endsubtxt:
End Sub
I cannot figure out how to make is stop looping after the last person