Code:
Private Sub Form_Current()
CheckColor
End Sub
Public Sub CheckColor2()
'using a recordset will be faster, but you might not notice
Dim rs As dao.Recordset
'get the recordset from the subform
Set rs = Me.frm_TESTVER_TEST_HIST.Form.Recordset.Clone
'search for POSITIVE in the subform's recordset
rs.FindFirst "[TestResult] = 'POSITIVE'"
'if POSITIVE wasn't found, go grey
If rs.NoMatch Then
Me.Detail.BackColor = -2147483633
'otherwise, go red
Else
Me.Detail.BackColor = 255
End If
'close the recordset
rs.Close
'make sure you clean up your objects
Set rs = Nothing
End Sub
Public Sub CheckColor()
'use the built in DLookup function... it's a bit slower
'if no records exist for this SS with POSITIVE, go grey
If IsNull(DLookup("TestResult", "tbl_TESTS", "EmpSS = '" & Me.SSN & "' AND TestResult = 'POSITIVE'")) Then
Me.Detail.BackColor = -2147483633
'otherwise, go red
Else
Me.Detail.BackColor = 255
End If
End Sub
This is a code that compairs a field in a subform to a field in the current form. It works great now. I need to make one change I am not sure how. Right now if a previous test is "POSITIVE" the current screen will go red. I need to change it to say IF a pervious test is "POSITIVE" OR "REFUSAL" then go red.
It looks like I am going to make 2 changes, but I am not sure how to do it correctly. Thank you all for the advice.