Alarm on a Form

C

Cesar

Hello everybody,

I have a Form where the user fills up with data from a daily inspection of
some equipment, one of these values is a Temperature, which is critical if is
above 170 Deg. Is there a way to change the Font color of the Text box
(Temperature) if the value entered is above 170? (Normal Font, black and size
10 below 170 Deg; Bold, red and size 10 above 170 Deg).
 
D

DStegon via AccessMonster.com

ON the AfterUpdate event of Temperature field you can make a Select Case
Block that will allow you to change the font, color, etc.
I am using a txt box called Qualifier (not knowing what your might be) and
when someone enters the value and presses enter or tab or moves to another
text box on your form the AfterUpdate event will fire. THe code below shows
how you can read the new value and then basically so anything you want based
on any number of "cases" you want to set in the Select Case Block.

Private Sub txtQualifier_AfterUpdate()
Dim lngTemp As Long

lngTemp = CLng(Me.txtQualifier)

Select Case lngTemp

Case Is > 170
With Me.txtQualifier
.FontItalic = True
.FontBold = True
.FontSize = 24
.ForeColor = vbBlack
End With

Case Is = 170
'DO WHATEVER HERE


Case Is < 170
'DO WHATEVER HERE

End Select


End Sub
 
D

DStegon via AccessMonster.com

opppsss .ForeColor = vbBlack should be .ForeColor = vbRed for your example
but you can turn it any color you want including any RGB color (just RGB(255,
0, 0) )
 
C

Cesar

Thanks both of you, both options work perfect, I never thought about the
Format Conditioning duh!
Thanks, you guys are genius!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top