Need Help

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Can someone help me. I am new at access. I have a form, which was created
from a query that has several text fields whcih I use for inputting
measurements.These fields are labled 1,2,3,4,5,6. There is also the same
number of field for the exact measurement I use for verification. There are
two other filelds that contain a +/- tolerence numbers. These two field are
inputs from another table. I would like to be able to determine if the
measurement i have inputted to any given field could
indicate if it was out of tolerance. I would like the box that indicated an
out of
tolerance condition have the number in red. Is this possible, and could
someone help me with this?
 
Ron - one way to do this would be to use this expression in the Form_Current
event of your form:

Private Sub Form_Current()
On Error GoTo Err_Form_Current

If Me!txt1errorPlus - Me!txtMarginErrorPlus > 0 Or _
Me!txt1errorPlus - Me!txtMarginErrorMinus < 0 Then
Me!txt1error.ForeColor = RGB(255, 0, 0)
Else
Me!txt1error.ForeColor = RGB(0, 0, 0)
End If

Exit_Form_Current:
Exit Sub
Err_Form_Current:
MsgBox Err.Description
Resume Exit_Form_Current
End Sub

This assumes that in the form, you name the controls "txt1measured" and
"txt1actual," then add a calculated field called txt1error. The expression
for the Control Source of that calculated field is:
=[txt1measured]-[txt1actual].

The comparison expression above could be simplified using the Absolute Value
function if you were using a single +/-number for the margin of error, but
you said there are two fields for the margin of error so the two numbers
must be different, so it's necessare to use something equivalent to what
I've shown above.

Good luck,

Paul
 
Ron - I changed one of the control names in the code I posted again below so
it would be more meaningful:

Private Sub Form_Current()
On Error GoTo Err_Form_Current

If Me!txt1error - Me!txtMarginErrorPlus > 0 Or _
Me!txt1error - Me!txtMarginErrorMinus < 0 Then
Me!txt1error.ForeColor = RGB(255, 0, 0)
Else
Me!txt1error.ForeColor = RGB(0, 0, 0)
End If

Exit_Form_Current:
Exit Sub
Err_Form_Current:
MsgBox Err.Description
Resume Exit_Form_Current
End Sub

This assumes that in the form, you name the controls "txt1measured" and
"txt1actual," then add a calculated field called txt1error. The expression
for the Control Source of that calculated field is:
=[txt1measured]-[txt1actual].

The comparison expression above could be simplified using the Absolute
Value
function if you were using a single +/-number for the margin of error, but
you said there are two fields for the margin of error so the two numbers
must be different, so it's necessare to use something equivalent to what
I've shown above.

Good luck,

Paul
 
Back
Top