Format Textbox on report depending on content

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Libra79
    New Member
    • May 2008
    • 4

    Format Textbox on report depending on content

    Hi,

    I am looking into changing the backcolor of a report text box depending if the data for that record contains a portion of a string.

    the field is a text field. If it were a query i know how to filter the data: like "*XYZ*" but in VB i don't know how to do it.

    How can i do that in a simple way, like an If [Field] contains "XYZ" then
    field.backcolor =76

    thanks,
  • nico5038
    Recognized Expert Specialist
    • Nov 2006
    • 3080

    #2
    You can use the Instr() function like:
    Code:
    IF Instr([fieldname],"XYZ") > 0 then
       ' action found
    else
      ' action not found
    end if
    The Instr() returns the the position the string "XYZ" is found.

    Nic;o)

    Comment

    • Libra79
      New Member
      • May 2008
      • 4

      #3
      Works,

      Thank you very much.

      Comment

      • nico5038
        Recognized Expert Specialist
        • Nov 2006
        • 3080

        #4
        You're welcome, success with your application !

        Nic;o)

        Comment

        Working...