Conditional textbox format on Form

foxhound

Board Regular
Joined
Mar 21, 2003
Messages
182
Hello,

I have nine text boxes: box_Q1, box_quart1, box_Q2, box_quart2, box_Q3, box_quart3, box_Q4, box_quart4, box_quarter. I would like help to do the following...if box_quarter is "first" I would like box_Q1's background color to be yellow and box_quart1 to be raised with a solid, hairline border. All others' back color and border should be etched.

If box_quarter is "second" I would like box_Q2's background color to be yellow and box_quart2 to be raised with a solid, hairline border. All others' back color and border should be etched. Etc....

Whenever I change records in the form, I need to determine the new value of box_quarter and do the same. Any help offered would be greatly appreciated :)
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
The best way to do this sort of thing is to write one Public Function in a Module and then Call that Function from different form-level events:
Code:
Public Function Format_Forms()
If Forms!Your_Form.Form!Box_Quarter="First" Then
'Code To Format Your TextBoxes goes here; look-up the Text Box's 'Properties to determine how to format them the way you want
Elseif Forms!Your_Form.Form!Box_Quarter="Second" Then
'Same Thing Here
End If
End Function

You would then call this function from Form-Level Events:
Code:
Form_Current()
'The Current event fires as you move from record to record
Call Format_Forms
End Sub

Code:
Box_Quarter_After_Update()
'The After_Update event would fire if you changed the text in the 'Box_Quarter Textbox
Call Format_Forms
End Sub

The idea is that you're sharing code throughout your application rather than reinventing the wheel.
 
Upvote 0

Forum statistics

Threads
1,221,569
Messages
6,160,557
Members
451,656
Latest member
SBulinski1975

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top