M
mj
Hi. I have some code that loops throught a recordset and
sends specific information (backOrders) to a specific
person via email. The recordset has multiple lines for
each recipient. I have one query that I use to pull my
email addresses from and another query with the data. I
make each line in the dataset a different line in the
message body. It works great except that, after I send a
person's information to them, the next person in the list
not only get's their own information, but also the
information from anyone who is in front of them in the
list of recipients. I must have something wrong with my
loop that appends one persons BackOrder set to the people
ahead of them in the list, but I can't figure it out. Any
suggestions would be great!
Set Db = CurrentDb
'This is my list of reps
Set rsBackOrderReps = Db.OpenRecordset("SELECT * " & _
"FROM [qryBackOrderReps]")
If Not rsBackOrderReps.EOF Then
Do While Not rsBackOrderReps.EOF
'This is my dataset
Set rsBackOrders = Db.OpenRecordset("SELECT * " & _
"FROM [qryBackOrders] WHERE [SalesRep]= '" &
rsBackOrderReps![SalesRep] & "'")
If Not rsBackOrders.EOF Then
Do While Not rsBackOrders.EOF
BackOrders = BackOrders & rsBackOrders!
[BackOrder] & vbCrLf
rsBackOrders.MoveNext
Loop
End If
Msg = BackOrders
DoCmd.SendObject
acSendNoObject, , , "Recipient", , , "BackOrders", Msg,
False
rsBackOrderReps.MoveNext
Loop
End If
sends specific information (backOrders) to a specific
person via email. The recordset has multiple lines for
each recipient. I have one query that I use to pull my
email addresses from and another query with the data. I
make each line in the dataset a different line in the
message body. It works great except that, after I send a
person's information to them, the next person in the list
not only get's their own information, but also the
information from anyone who is in front of them in the
list of recipients. I must have something wrong with my
loop that appends one persons BackOrder set to the people
ahead of them in the list, but I can't figure it out. Any
suggestions would be great!
Set Db = CurrentDb
'This is my list of reps
Set rsBackOrderReps = Db.OpenRecordset("SELECT * " & _
"FROM [qryBackOrderReps]")
If Not rsBackOrderReps.EOF Then
Do While Not rsBackOrderReps.EOF
'This is my dataset
Set rsBackOrders = Db.OpenRecordset("SELECT * " & _
"FROM [qryBackOrders] WHERE [SalesRep]= '" &
rsBackOrderReps![SalesRep] & "'")
If Not rsBackOrders.EOF Then
Do While Not rsBackOrders.EOF
BackOrders = BackOrders & rsBackOrders!
[BackOrder] & vbCrLf
rsBackOrders.MoveNext
Loop
End If
Msg = BackOrders
DoCmd.SendObject
acSendNoObject, , , "Recipient", , , "BackOrders", Msg,
False
rsBackOrderReps.MoveNext
Loop
End If