Need help with conditional Formating. (1 Viewer)

tucker61

Registered User.
Local time
Today, 01:08
Joined
Jan 13, 2008
Messages
321
Hi guys, trying to conditional format a field if the value is <> a set tolerance.

I have got so far, My TBControlMeasurement = 93, My Tolerance is 2, so i have a upper and lower limit set,
So if the Value in Sample_1 is either higher than the upperlimit, or lower than the lower limit i would want this to turn red.

I need to do this for 15 fields on the Form (Sample 1-15) so not sure what is the easiest way to do this as well.


Code:
Private Sub Sample_1_AfterUpdate()
Dim upperlimit As Integer
Dim lowerlimit As Integer
upperlimit = TBControlMeasurement + Tolerance
lowerlimit = TBControlMeasurement - Tolerance

With [Sample_1].FormatConditions
.Delete
With .Add(acExpression, acEqual, "(([upperlimit]-[Sample_1])>0)")
.BackColor = vbRed
End With
End With
End Sub
 

Gasman

Enthusiastic Amateur
Local time
Today, 09:08
Joined
Sep 21, 2011
Messages
14,238
Hi guys, trying to conditional format a field if the value is <> a set tolerance.

I have got so far, My TBControlMeasurement = 93, My Tolerance is 2, so i have a upper and lower limit set,
So if the Value in Sample_1 is either higher than the upperlimit, or lower than the lower limit i would want this to turn red.

I need to do this for 15 fields on the Form (Sample 1-15) so not sure what is the easiest way to do this as well.


Code:
Private Sub Sample_1_AfterUpdate()
Dim upperlimit As Integer
Dim lowerlimit As Integer
upperlimit = TBControlMeasurement + Tolerance
lowerlimit = TBControlMeasurement - Tolerance

With [Sample_1].FormatConditions
.Delete
With .Add(acExpression, acEqual, "(([upperlimit]-[Sample_1])>0)")
.BackColor = vbRed
End With
End With
End Sub
Wouldn't you need code like that on form load?
 

Users who are viewing this thread

Top Bottom