Hi
I am trying to set up a procedure that loops through a recordset and sends an email to each record in the recordset.
The query underlying the recordset selects on a date criterion and also if a field, bNotif is 0.
I have built a continuous form based on the underlying qryExpDrug and there is a button saying "send emails" on the form. The relevant bit of the code I have managed to get to is this
It does exactly what I want it to on the first run through in that the first and second emails are exactly as expected. However once I send the email for the second record it seems to stick on it and the bNotif field does not update.
Can anyone show me what I have got wrong here or alternatively point me in a better direction?
ANy help much appreciated
Best wishes
I am trying to set up a procedure that loops through a recordset and sends an email to each record in the recordset.
The query underlying the recordset selects on a date criterion and also if a field, bNotif is 0.
I have built a continuous form based on the underlying qryExpDrug and there is a button saying "send emails" on the form. The relevant bit of the code I have managed to get to is this
Code:
rst.Open "qryExpDrug", cnn, adOpenDynamic, adLockOptimistic
With rst
Do While Not .EOF
.MoveLast
.MoveFirst
DoCmd.SendObject , , , Me!txtGpEm, , , "XXX - Issued drug expiry advice", "Dear " & Me!txtGpName & "," & CR & "On " & Me!txtIssue & " we issued you with " & Me!txtQty & " " & Me!txtDrugFormat & " of " & Me!txtDrugName & ". The manufacturer was " & Me!txtMan & " and the batch number was " & Me!txtBatch & ". This batch was has an exiry date of " & Me!txtExp & " which is now approaching." & CR & CR & "XXX" & CR & "XXX" & CR & "XXX" & CR & "XXX", , True
.Fields("bNotif") = -1
.Update
.MoveNext
Me.Requery
Loop
.Close
End With
Can anyone show me what I have got wrong here or alternatively point me in a better direction?
ANy help much appreciated
Best wishes