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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Criteria-based row colours

Status
Not open for further replies.

R34LiSM

Programmer
May 16, 2002
10
GB
Hi all

I'd very much like to change the background of each row in my report, based on what results it contains. Here's the pseudo-code;

If class.value < 1 Then row.bgcolour=red
Else row.bgcolour=white
End If

Can anyone help me with this please? I've tried a couple of basic approaches but had no success.
 
The answer may come in the question Where are you running this code from ?


Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

If class.value < 1 Then
Detail.BackColor = 255 ' Red
Else
Detail.BackColor = 16777215 ' White
End If

End Sub



QED.

G LS
 
MINOR change. Generally, you will need to (fully) qualify the section, and place these in the Detail OnPrint event.

Code:
Private Sub Detail_Print(Cancel As Integer, FormatCount As Integer)

If (class.value < 1) Then 
    Me.Section(&quot;Detail&quot;).BackColor = 255       ' Red
 Else 
    Me.Section(&quot;Detail&quot;).BackColor = 16777215   ' White
End If

End Sub
MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
Thanks for the continued assistance, getting there slowly but surely!

smiletiniest.gif
 
I'm interested in your comment Michael because I've not come across a problem when I've used the unqualified names in the Detail_Format event.

Why should it matter if there isn't a conflict anywhere.

And why On_Print ? At least with On_Format the user gets to see it ( In Preview Mode ) on the screen as well as on the printer.


I'll be interested to know if you have any background on the why ?


G LS
 
I probably just tend to be a bit conservative (somtimes I have been refered to a being to the extreme right of Atillia - just because I refered to him as one of those &quot;flaiming left wigner's&quot;. I usually refer to the various sections of a report via their name, mostly for documentation purposes.

The reason for the use of the OnPrint event is that their is also a 'retreat' event between the format and print events. After thinking about it, it is probably immaterial to this procedure. I more often just use alternating LtGrey / White backgrounds, and force the first record of each page to have the LtGrey background, so it is possible for the record position (page) to change if the retreat event occurs, and that messes about with the alternating scheme, and first rec being set to LtGrey. When running moderqte to large reports, this WILL occur and the angst in the report recipients is occassionally difficult to witness.

I can &quot;see&quot; the shading using the OnPrint event, in the print prieview, so the &quot;OnFormat&quot; event for the user is -IMO- a moot point.

MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top