I need some process help for moving next in a do loop when the if statement condition is met. I am opening a recordset that contains 3 date fields and a serial number. I have 4 If statements.. My Update statements are working well but I cannot figure out how to process the operations to move to the next record and execute the action consistently
1.) If the FirstEmailDate field for the serial number record is not populated then populate the current date and rs.movenext
2.) otherwise if FirstEmailDate is populated and SecondEmailDate is not populated then populate the current date into SecondEmailDate and rs.movenext
3.) otherwise if FirstEmailDate and SecondEmailDate fields are populated then populate the current date into ThirdEmailDate and rs.movenext
4.) otherwise if FirstEmailDate and SecondEmailDate and Third EmailDate fields are populated then MsgBox that threshold has been met, user clicks ok and rs.movenext
1.) If the FirstEmailDate field for the serial number record is not populated then populate the current date and rs.movenext
2.) otherwise if FirstEmailDate is populated and SecondEmailDate is not populated then populate the current date into SecondEmailDate and rs.movenext
3.) otherwise if FirstEmailDate and SecondEmailDate fields are populated then populate the current date into ThirdEmailDate and rs.movenext
4.) otherwise if FirstEmailDate and SecondEmailDate and Third EmailDate fields are populated then MsgBox that threshold has been met, user clicks ok and rs.movenext
Code:
Set rs0 = DB.OpenRecordset(strSQL0) If rs0.EOF Then rs0FindRecordCount = 0 Else rs0.MoveLast rs0.MoveFirst Do Until rs0.EOF rs0FindRecordCount = rs0.RecordCount SNComment = rs0.u_serial_number If Nz(Forms![BigFix Management Form].First_Email_Date, "") = "" Then CurrentDb.Execute "UPDATE Status_and_Updates SET [First_Email_Date]" & _ "= '" & vardate & "' WHERE [u_serial_number] = '" & SNComment & "'" rs0.MoveNext ElseIf Nz(Forms![BigFix Management Form].Second_Email_Date, "") = "" Then CurrentDb.Execute "UPDATE Status_and_Updates SET [Second_Email_Date]" & _ "= '" & vardate & "' WHERE [u_serial_number] = '" & SNComment & "'" rs0.MoveNext ElseIf Nz(Forms![BigFix Management Form].Third_Email_Date, "") = "" Then CurrentDb.Execute "UPDATE Status_and_Updates SET [Third_Email_Date]" & _ "= '" & vardate & "' WHERE [u_serial_number] = '" & SNComment & "'" rs0.MoveNext End If If Nz(Forms![BigFix Management Form].Third_Email_Date, "") <> "" & Nz(Forms![BigFix Management Form].Second_Email_Date, "") <> "" & Nz(Forms![BigFix Management Form].First_Email_Date, "") <> "" Then MsgBox "This device or user has already received 3 emails!" & vbCrLf & _ "This user is now a candidate for account lockout." & vbCrLf & _ "Please email this user's name " & rs0.UserName & vbCrLf & _ "and their system: " & rs0.u_serial_number & " to you manager at this time", , "User has reached lockout point" End If rs0.MoveNext Loop
Comment