04-24-15, 21:35 #1Registered User
- Join Date
- May 2014
Unanswered: conditional formatting on option box
I have a continuous form. On which I have a frame and three option boxes with values 1, 2 and 3 what I am trying to do if one record is selected in option box other text boxes of the same record turn red I am using this code which works perfectly expect that it's doing for all records. I want that particular record to turn red.
Private Sub Form_current() FormatGroup End Sub ' Private Sub Frame53_Click() FormatGroup End Sub Sub FormatGroup() Select Case Frame53 Case 1 OrderNumber1.BackColor = vbRed ProductName1.BackColor = vbRed VNumber1.BackColor = vbRed Case 2 OrderNumber1.BackColor = vbYellow ProductName1.BackColor = vbYellow VNumber1.BackColor = vbYellow Case 3 OrderNumber1.BackColor = vbGreen ProductName1.BackColor = vbGreen VNumber1.BackColor = vbGreen ' Case Else ' grpBooked.BackColor = vbYellow End Select End Sub
04-26-15, 11:05 #2Moderator
Provided Answers: 19
- Join Date
- Jun 2005
- Richmond, Virginia USA
That's how Continuous View Forms work...the formatting of a given control on one record is applied to that control on all records, when done through code! The only way around this is to use Conditional Formatting off of the menu or ribbon, depending on version. Here's a step-by-step for doing it for OrderNumber1; after doing this simply repeat the steps for ProductName1 and VNumber1. In Form Design View:
- Right Click OrderNumber1
- Click on Conditional Formatting
- Under Condition1 select Expression Is
- In the next box enter [Frame53] = 1
- Use the BackColor ('bucket') icon and select Red from the palette
- Hit Add
- Under Condition2 select Expression Is
- In the next box enter [Frame53] = 2
- Use the BackColor ('bucket') icon and select Yellow from the palette
- Hit Add
- Under Condition3 select Expression Is
- In the next box enter [Frame53] = 3
- Use the BackColor ('bucket') icon and select Green from the palette
- Hit OK
Do this for all three Controls and you're done!
Last edited by Missinglinq; 04-26-15 at 12:06.Hope this helps!
The problem with making anything foolproof...is that fools are so darn ingenious!
All posts/responses based on Access 2003/2007