Results 1 to 3 of 3
  1. #1

    Conditional Reporting (2000)

    I want to have a text box on my report that changes colors based on the value of the record. For example, I have values of High, Medium and Low. If it's Low I would like the text box to be colored Red, etc. Sort of a fudged bar chart - because I can't use a chart. Does anyone know if this is possible?

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Sint Niklaas, Belgium
    Thanked 0 Times in 0 Posts

    Re: Conditional Reporting (2000)

    Put code like this in the On format event of the detail of the report:

    <pre>Private Sub Detail1_Format(Cancel As Integer, FormatCount As Integer)
    Select Case Me!TextBox
    Case "Low"
    Me!TextBox.BackColor = vbRed
    Case "High"
    Me!TextBox.BackColor = vbBlue
    Case "Medium"
    Me!Textbox.backcolor = vbGreen
    Case Else
    Me!TextBox.BackColor = vbWhite
    End Select
    End Sub

    For the colors, you can use the numbers instead of vba constants.
    To get those numbers, change the Back or Fore color in the properties of the textbox in design mode. When you click on a color or click OK you will see a number in the property box. Get that number an use it in the code. Keep in mind that, depending on your printer and/or videocard, these colors can be a little different on paper.
    You can also change the for color. Insert a line like
    <pre>Me!TextBox.ForeColor = vbYellow</pre>



  3. #3

    Re: Conditional Reporting (2000)

    This worked great, thanks so much. Although, I used the Detail_Preview option because the Format option wasn't working as expected. But thanks for leading me in the right direction!!!

Posting Permissions

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