Changing border of text box depending on value of field

tb5038

Registered User.
Local time
Today, 06:58
Joined
Jan 6, 2014
Messages
32
Hi,

I have a box with age in called [agecalc]. I want to change the border of the box to red to indicate they are a Juvenile if under the age of 17.

I already have some code to write the text, I just need to change the border of this text box called agebox

=IIf([agecalc]<=17,"Juvenile!!")

Thanks

TJ
 
Do it in VBA, go to design view, select Event tab and select Event Procedure under OnCurrent. Now write this

Code:
If Me.AgeCalcControlName<=17 Then
Me.AgeCalcControlName.BorderColor=RGB(255, 0, 0)
Else: Me.AgeCalcControlName.BorderColor=RGB(63, 63, 63)
End If

These colors are red and black. If you want other colors you need to look up the RGB values. In VB you can use Color.ColorName but I don't think you can in VBA but not 100% sure.

BTW, I like to change the color of the text rather than the borders (just think it looks better) to do that use .ForeColor instead of .BorderColor

Good luck!
 

Users who are viewing this thread

Back
Top Bottom