Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Lewes, East Sussex, Sussex, United Kingdom
    Posts
    232
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Subforms & conditional formatting (A2003 SP1)

    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

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Subforms & conditional formatting (A2003 SP1)

    A subform is not part of the Forms collection, only main forms are. Try changing strCond to
    <code>
    strCond = "[txtCategory]='S' or [txtCategory]='T'"
    </code>
    or
    <code>
    strCond = "[txtCategory] In ('S','T')"
    </code>
    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.

  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Lewes, East Sussex, Sussex, United Kingdom
    Posts
    232
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Subforms & conditional formatting (A2003 SP1)

    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

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Subforms & conditional formatting (A2003 SP1)

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

    Ok, that's a good reason.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •