I am using the following code to send e mail notifications if people are within 30 days of needing training, then if the training is over due another e mail gets sent.
Private Sub Form_Current()
If (Forms![frmEmailWarnings]![ TngDueEmailSent] = 0) Then
Dim rsEmail As DAO.Recordset
Dim strEmail As String
Set rsEmail = CurrentDb.OpenRecordset("qryTngDue")
Do While Not rsEmail.EOF
strEmail = rsEmail.Fields("Email").Value
DoCmd.SendObject , , , strEmail, , , "training Due soon", " training will be due soon. Please get scheduled for this training as soon as possible. ", True
Me. TngDueEmailSent = -1
rsEmail.MoveNext
Loop
Set rsEmail = Nothing
End If
If (Forms![frmEmailWarnings]![ TngOverdueEmailSent] = 0) Then
Set rsEmail = CurrentDb.OpenRecordset("qryTngOverdue")
Do While Not rsEmail.EOF
strEmail = rsEmail.Fields("Email").Value
DoCmd.SendObject , , , strEmail, , , "training Is Overdue", "You have not attended training in the past year. It is important the training is completed in order to get you current again. Please secure this training as soon as possible. Thank You", True
Me.TngOverdueEmailSent = -1
rsEmail.MoveNext
Loop
Set rsEmail = Nothing
End If
End sub
Basically, what I want is for the code to check the query, then
send an email to all on the query (the query selects all that need the yearly training), then
mark each record’s e mail sent yes/no field to yes after the email is sent, (so the e mail only gets sent once), then
somehow reset the yes/no field to NO after the new cycle starts(after the training is completed) so the e mail can be sent when the training becomes overdue again.
I have about 15 items that I want to send notifications for. My problem is that with the following code the e mail gets sent but the yes/no fields only get updated for the first record in the database
[This message has been edited by hilbertm (edited 12-21-2001).]
Private Sub Form_Current()
If (Forms![frmEmailWarnings]![ TngDueEmailSent] = 0) Then
Dim rsEmail As DAO.Recordset
Dim strEmail As String
Set rsEmail = CurrentDb.OpenRecordset("qryTngDue")
Do While Not rsEmail.EOF
strEmail = rsEmail.Fields("Email").Value
DoCmd.SendObject , , , strEmail, , , "training Due soon", " training will be due soon. Please get scheduled for this training as soon as possible. ", True
Me. TngDueEmailSent = -1
rsEmail.MoveNext
Loop
Set rsEmail = Nothing
End If
If (Forms![frmEmailWarnings]![ TngOverdueEmailSent] = 0) Then
Set rsEmail = CurrentDb.OpenRecordset("qryTngOverdue")
Do While Not rsEmail.EOF
strEmail = rsEmail.Fields("Email").Value
DoCmd.SendObject , , , strEmail, , , "training Is Overdue", "You have not attended training in the past year. It is important the training is completed in order to get you current again. Please secure this training as soon as possible. Thank You", True
Me.TngOverdueEmailSent = -1
rsEmail.MoveNext
Loop
Set rsEmail = Nothing
End If
End sub
Basically, what I want is for the code to check the query, then
send an email to all on the query (the query selects all that need the yearly training), then
mark each record’s e mail sent yes/no field to yes after the email is sent, (so the e mail only gets sent once), then
somehow reset the yes/no field to NO after the new cycle starts(after the training is completed) so the e mail can be sent when the training becomes overdue again.
I have about 15 items that I want to send notifications for. My problem is that with the following code the e mail gets sent but the yes/no fields only get updated for the first record in the database
[This message has been edited by hilbertm (edited 12-21-2001).]