Forum Discussion

ChrisAKFS's avatar
ChrisAKFS
Copper Contributor
Jul 22, 2024
Solved

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...
  • Gerrit_Viehmann's avatar
    Jul 23, 2024

    ChrisAKFS 

    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

     

Resources