• Subforms & conditional formatting (A2003 SP1)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Subforms & conditional formatting (A2003 SP1)

    Author
    Topic
    #445357

    I have a problem with conditional formatting on subforms which I wonder if somebody can help me with.

    I have created a couple of subforms, and programmatically added this conditional formatting on the Load event :

    strCond = “forms(‘fsubMainAssets’)!txtCategory=’S’ or forms(‘fsubMainAssets’)!txtCategory=’T'”
    Me!txtAmount.FormatConditions.Delete
    Set ftc = Me!txtAmount.FormatConditions.Add(acExpression, , strCond)
    With ftc
    .FontBold = True
    .BackColor = gclngBackColor
    End With

    This works perfectly when I open the subform on its own. However, when I open the parent form on which the subform is located, the code runs but has no effect. I have tried using a Repaint, Requery and Refresh on the subform, but that has no effect either.

    Does anyone have any ideas as to why this is not working, and how to get round it ?

    Usual thanks for your expert help

    Viewing 0 reply threads
    Author
    Replies
    • #1079694

      A subform is not part of the Forms collection, only main forms are. Try changing strCond to

      strCond = "[txtCategory]='S' or [txtCategory]='T'"

      or

      strCond = "[txtCategory] In ('S','T')"

      BTW why do you want to set this in code? The conditional formatting is not dynamically defined, so you could set it in design view.

      • #1079706

        Hans

        As always you are completely spot on – this fixed the problem in an instant.

        The reason I was using code was because I wanted to set the background colour to one that was not on the palette (a shade of light blue). I don’t know of any other way of doing this except in code.

        Thanks again

        Nick

        • #1079707

          > because I wanted to set the background colour to one that was not on the palette

          Ok, that’s a good reason.

    Viewing 0 reply threads
    Reply To: Subforms & conditional formatting (A2003 SP1)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: