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

Conditional Color in Detail Band

Status
Not open for further replies.

kamweng

Programmer
Jan 20, 2012
36
0
0
MY
I have just learnt how to use the VFP9 (SP1) Report Writer.
Now I wonder is it possible to have conditional foreground (pen) color in the Detail Band.

I have searched the FQA, help file and the KEYWORD "Detail Band", but could not find an answer.

I tried "IIF(dbr.tb <= 0, forecolor = RGB(255,0,0), forecolor = RGB(0,0,0))" in the format tab but failed.

Your guildance will be greatly appreciated. Thank you.

 
Maybe someone else might have a better idea, but have you tried the following?

1. Place 2 textboxes in the Detail band to represent each of the items/values you want displayed.
2. Make the color properties of each the way you want them to be for the 2 different circumstances - that is make one with a RGB(0,0,0) foreground (font color) and the other with a RGB(255,0,0) foreground
3. Now use the Print When... expression to control which prints when -
One to Print When dbr.tb <= 0 and the other to Print When dbr.tb > 0
4. Physically move the textboxes so that for any given value the 2 textboxes fully physically over-laps the other - it should not matter which is on top or not.

That method has worked for me in the Report Form versions prior to VFP9 so I'm guessing that it will continue to work in VFP9

Good Luck,
JRB-Bldr
 
JRB said:
Maybe someone else might have a better idea, but have you tried the following?

I don't think you'll find a better method.

It's possible to do this sort of thing with a custom report listener, but it's complicated, and requires some knowledge of how report listeners work. The method that JRB suggested is the usual way of doing it.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
In the Dynamics tab of the Field Poperties window you can add conditions, this works quite like a case statement. Name your condition, then set the conditions expression and set the pen foreground/background color as wanted. That's not giving you direct assignment of an rgb value from a field, but you can define 2,3,...N colors and activate each via some condition like balance<0 for red, balance= for white and balance>0 for black.

Bye, Olaf.
 

I'm using Google Translator :) Solution for the VFP 9
kamweng, put an attachment here, but I'll explain what I did.

I created the report and put a Fields, right clicked and went in there and Dynamics created the conditions that I wanted, take a look when put something here.
 
 http://www.sendspace.com/file/g99nbm
lardecristo, Thank you for your help but I could not open the exe because of the SetDefPr "Printer Device Name". My default printer is "EPSON ME 620F Series". Please untick the SAVE PRINTER ENVIRONMENT in the page setup. Thank you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top