Using Office 365, I have an Access database that generates an email. Currently it loops through a recordset to determine if any records are greater than 30 minutes in duration. If they are, they appear in red font in an HTML table in the body of the email, if not, then black. The database is tracking downtime duration for multiple equipment stations. Below is a snippet of my original code.
I have now been asked to also have any repeat station incidents show up in a red font as well.
For example, the recordset I am currently using to test has 17 records in it. Of those 17, there are 3 repeats for one station and 7 repeats for another station. So, I created another recordset that would only display the repeated station numbers. I altered my code, above, as follows:
However, now the results are duplicating the records and I end up with 34 records returning instead of 17. So, I thought I could use a filter, but I am struggling to get the results I need. Does anyone have any suggestions that might help? Thank you.
Code:
rsDowntime.MoveFirst
Do While Not rsDowntime.EOF
If rsDowntime!Duration >=30 Then
….red font
Else
…black font
End If
rsDowntime.MoveNext
Loop
rsDowntime.Close
I have now been asked to also have any repeat station incidents show up in a red font as well.
For example, the recordset I am currently using to test has 17 records in it. Of those 17, there are 3 repeats for one station and 7 repeats for another station. So, I created another recordset that would only display the repeated station numbers. I altered my code, above, as follows:
Code:
rsDowntime.MoveFirst
Do While Not rsDowntime.EOF
rsPlus3.MoveFirst
Do While Not rsPlus3.EOF
If rsDowntime!Duration >=30 Or rsPlus3!Station = rsDowntime!Station Then
….red font
Else
…black font
End If
rsPlus3.MoveNext
Loop
rsDowntime.MoveNext
Loop
rsDowntime.Close
rsPlus3.Close
However, now the results are duplicating the records and I end up with 34 records returning instead of 17. So, I thought I could use a filter, but I am struggling to get the results I need. Does anyone have any suggestions that might help? Thank you.