Forum Discussion
ChrisAKFS
Jul 22, 2024Copper Contributor
Text Box Conditional Formatting
Hi I have a database of circa 100 audit questions and for each answer is a combo box for Yes: meets the standard, No: Minor NC, No: Major NC, OFI and N/A. I would like to be able to format the f...
- Jul 23, 2024
There are many ways to archive this, but conditional formatting is fine.
I assume you have copied all desired formatting from the text field Question001 (or similar) to the other text fields named Question plus a number. (Double click on the brush in the ribbon enables multiple copies.)The combo boxes Answer001 to Answer100 (or similar) must also exist in the same form "Audit_Results".
Then you can correct the missaligned conditional format expressions per code:
E.g:Private Sub C_F_Expr_Modify() Dim i As Long, j As Long For i = 2 To 100 With Forms!Audit_Results!Controls("Question" & Format$(i, "000")) For j = 0 To 4 .FormatConditions(j).Modify Type:=acExpression, Operator:=acEqual, Expression1:=Replace(.FormatConditions(j).Expression1, "001", Format$(i, "000")) Next j End With Next i End Sub
ChrisAKFS
Jul 22, 2024Copper Contributor
Thanks for that George. I have done some VBA on other databases but often had to seek further help when something wouldn't quite work.
George_Hepworth
Jul 22, 2024Silver Contributor
Google is your friend when seeking help. And for specific problems, forums like this are good.
If I were starting over, I'd invest time in learning more about classes because one of the things they can do for you is make tasks like conditional formatting much easier to implement in new forms. That's the power of classes, in fact. Create a class for CFComboBoxes in a single class module and every combo box in that application can use it.
If I were starting over, I'd invest time in learning more about classes because one of the things they can do for you is make tasks like conditional formatting much easier to implement in new forms. That's the power of classes, in fact. Create a class for CFComboBoxes in a single class module and every combo box in that application can use it.