monplankton
Registered User.
- Local time
- Today, 11:07
- Joined
- Sep 14, 2011
- Messages
- 83
Hi, Not used loop function before and I'm struggling to understand how to set it up on my code.All works but does scroll to next record and repeats the code. Any help much appreciated.

Code:
Dim db As Database
Set db = CurrentDb
Dim recRework As DAO.Recordset
Set recRework = db.OpenRecordset("qry_list_of_jobs")
Do While Not recRework.EOF
If IsNull(Me.[FirstReminder]) And Date > Me.Threeweeks Then
Dim objOutlook As Outlook.Application, objMailItem As MailItem
Set objOutlook = New Outlook.Application
Set objMailItem = objOutlook.CreateItem(olMailItem)
With objMailItem
.to = Me.LastName & ", " & Me.FirstName
.CC = "[EMAIL="graham.atkins@uwclub.net"][COLOR=#0000ff]graham.atkins@uwclub.net[/COLOR][/EMAIL]"
.Subject = "3 week Reminder"
.Body = "Hi " & [FirstName] & "," & vbCrLf & "You currently have an ongoing rework on the Rework Management System." & " " & [Part Description] & "," & " " & [Rework Activity] & " " & "reworks order number" & " " & [WO Number] & " " & ", RCS Number" & " " & [RCS Number] & vbCrLf & "This rework is due to expire in 3 weeks time on " & [Planned Finish] & ". As you are aware, if the rework is to continue then a rework extension request should be raised and approved. Can you please ensure a rework extension request is raised and approved prior to this date." & vbCrLf & "Regards" & vbCrLf & "PQA Admin"
.Send
End With
Set objMailItem = Nothing
Set objOutlook = Nothing
Me.[FirstReminder] = Date
ElseIf IsNull(Me.[SecondReminder]) And Date > Me.Twoweeks Then
Set objOutlook = New Outlook.Application
Set objMailItem = objOutlook.CreateItem(olMailItem)
With objMailItem
.to = Me.LastName & ", " & Me.FirstName
.CC = "[EMAIL="graham.atkins@uwclub.net"][COLOR=#0000ff]graham.atkins@uwclub.net[/COLOR][/EMAIL]"
.Subject = "2 week Reminder"
.Body = "Hi " & [FirstName] & "," & vbCrLf & "Following our previous reminder, you currently have an ongoing rework on the Rework Management System." & " " & [Part Description] & "," & " " & [Rework Activity] & " " & "reworks order number" & " " & [WO Number] & " " & ", RCS Number" & " " & [RCS Number] & vbCrLf & "This rework is due to expire in Two weeks time on " & [Planned Finish] & ". If this rework is to continue then a rework extension request should be raised and approved prior to this date." & vbCrLf & "Regards" & vbCrLf & "PQA Admin"
.Send
End With
Set objMailItem = Nothing
Set objOutlook = Nothing
Me.[SecondReminder] = Date
ElseIf IsNull(Me.[ThirdReminder]) And Date > Me.Oneweek Then
Set objOutlook = New Outlook.Application
Set objMailItem = objOutlook.CreateItem(olMailItem)
With objMailItem
.to = Me.LastName & ", " & Me.FirstName
.CC = Me.SSecond & ", " & Me.SFirst & ";William.woodhouse@nissan-nmuk.co.uk;David.hambleton@nissan-nmuk.co.uk;ian.taylor@nissan-nmuk.co.uk;Tony.wardropper@nissan-nmuk.co.uk"
.Subject = "Rework Order"
.Body = "Hi " & [FirstName] & "," & vbCrLf & "Following our 2 previous reminders, you currently have an ongoing rework on the Rework Management System." & " " & [Part Description] & "," & " " & [Rework Activity] & " " & "reworks order number" & " " & [WO Number] & " " & ", RCS Number" & " " & [RCS Number] & vbCrLf & "Please be informed that this rework is now currently one week away from its expiry date of " & [Planned Finish] & vbCrLf & "PQA Inspection have yet to receive a rework extension request." & vbCrLf & "If the rework is to continue can you please submit an approved extension request within three working days." & vbCrLf & "Regards," & vbCrLf & "PQA Admin"
.Send
End With
Set objMailItem = Nothing
Set objOutlook = Nothing
Me.[ThirdReminder] = Date
ElseIf IsNull(Me.[Final Reminder]) And Date > Me.Twodays Then
Set objOutlook = New Outlook.Application
Set objMailItem = objOutlook.CreateItem(olMailItem)
With objMailItem
.to = Me.LastName & ", " & Me.FirstName
.CC = Me.SSecond & ", " & Me.SFirst & ";" & Me.MSecond & ", " & Me.MFirst & ";[EMAIL="graham.atkins@uwclub.net"][COLOR=#0000ff]graham.atkins@uwclub.net[/COLOR][/EMAIL]"
.Subject = "24 Hour Reminder"
.Body = "Hi " & [FirstName] & "," & vbCrLf & "As mentioned in previous e-mail correspondence, PQA Inspection have yet to receive a formal rework extension request for" & " " & [Part Description] & "," & " " & [Rework Activity] & " " & "reworks order number" & " " & [WO Number] & " " & ", RCS Number" & " " & [RCS Number] & " " & "which is now 24hrs from expiry.If the rework is to continue then an extension request must be received within the next 24hrs." & vbCrLf & "Failure to comply with this notification will result in the termination of the rework activity and the removal of the resource performing the operation tomorrow." & vbCrLf & "Regards" & vbCrLf & "PQA Admin"
.Send
End With
Set objMailItem = Nothing
Set objOutlook = Nothing
Me.[Final Reminder] = Date
recRework.MoveNext
Loop
recRework.Close
Set recRework = Nothing
End If
End Sub