Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Conditional formatting on Reports

Status
Not open for further replies.

willsth

Programmer
Oct 3, 2008
33
GB
Is it possible to do conditional formatting on a Label within a report, I know I get the option on the Control Source but what about the label attached to it
 
How are ya willsth . . .

Not much too go on here!. However as a test, in the [blue]On Format[/blue] event of the section that contains the labels, try:
Code:
[blue]   If [purple][b]YourConditon[/b][/purple] = True Then
      [LableName].Backcolor = 32768 'Green
      [LableName].ForeColorcolor = 65535 'Yellow
   Else
      [LableName].Backcolor = 16777215 'White
      [LableName].ForeColorcolor = 0 'Black
   End If[/blue]
[blue]Your Thoughts? . . .[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
I dont get the option 'Format' on this field
 
willsth said:
[blue]I dont get the option 'Format' on this field[/blue]
In my post I didn't mention an option. I mentioned a [blue]section event![/blue] Formatting in this way is different than the traditional [blue]Conditional Formatting[/blue] provided in the main menubar!

To be specific, a section is defined by the graybar (in report design view), such as the [blue]Detail Section[/blue]. If you have [blue]Report Header/Footer[/blue] section enabled (thru the View Menu), you'll have graybars for these in design view as well (with an arrow pointing down for the section in question).

As an example, if you click on the [blue]Detail bar[/blue] for the [blue]detail section[/blue], and select the [blue]event tab[/blue] of the [blue]properties window[/blue], you should see the [blue]On Format[/blue] event!

[blue]Your Thoughts? . . .[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
I have created a text box now with some text in it and I've got the following bit of code in ON FORMAT of the Report.
Basically if field 'Outstanding' is Zero then I dont want to show the 2 text fields, TxtOut and TxtStage

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If Nz(Me![Outstanding], "") = "" Then blVal = False Else blVal = True
Me!TxtOut.Visible = blVal
Me!TxtStage.Visible = blVal
End If
End Sub

Still not working
 

You are assigning the visible properties inside the same if clause that sets the blVal value. Try this instead...
Code:
If Nz(me!Outstanding,"") = "" Then
    blVal = False
Else
    blVal = True
End If
Me!txtOut.Visible = blVal
Me!txtStage.Visible = blVal


Randy
 
willsth . . .

Try this:
Code:
[blue]   If Trim([Outstanding] & "") = "" Then
      blVal = False
   Else
      blVal = True
   End If
   
   [TxtOut].Visible = blVal
   [TxtStage].Visible = blVal[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
I've tried the following piece of code just to try hide my fields with no success.

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Me.[TxtOut].Visible = False
Me.[TxtStage].Visible = False
End Sub

Is it to do with where my code is placed i.e. 'On Format' in detail section of my report
 
... and if you move the code to the [blue]On Print[/blue] event?

Note: I have no problem in A2K ...

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Sorted it thanks, apparently you can do conditional formatting on one field based on results from another. I should have tried this earlier.
Thanks for your help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top