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

Formating background in the details section

Status
Not open for further replies.

bbagai

Programmer
Jun 27, 2000
4
AU
I am currently working on reports which require alternate records to be shaded grey and white. I also want the new page to start with a grey background record. I cannnot start a new page after a fixed number of records as the page sizes where the report is printed may vary. Has anyone used global variables in Crystal? Has any one tried to do this before ?<br><br>thanks
 
Hello bbagai,<br><br>I hope the following answers some of your question:<br><br>Conditional Formatting<br>Section Expert<br>Shading every other (Even) record<br>If Remainder(RecordNumber,2)=0 then Grey else NoColor<br>//This will shade every other line Grey starting with line 2,4,6,etc.<br>//The Remainder function takes the RecordNumber, divides it by 2, and returns a remainder<br>//If the remainder is equal to zero, the RecordNumber is divisible by two and thus is an even //number triggering the colour Grey<br>//If the remainder is not equal to zero, the RecordNumber is not evenly divisible by two and thus //is an odd number, triggering NoColor<br>//Apply this to the Details Section<br><br>Shading every other (Odd) record<br>If Remainder(RecordNumber,2)&lt;&gt;0 then Grey else NoColor<br>//This will shade every other line Grey starting with line 1,3,5,etc.<br>//If the remainder is not equal to zero, the RecordNumber is not evenly divisible by two and thus //is an odd number, triggering Grey<br>//The Remainder function takes the RecordNumber, divides it by 2, and returns a remainder<br>//If the remainder is equal to zero, the RecordNumber is divisible by two and thus is an even //number triggering NoColor<br><br>Good Luck,<br>Michael
 
So, to get that method to always start with grey, then use a global variable instead of RecordNumber, and reset the value of the variable to one in the page header, and increment it in the detail section.<br>Variables in Crystal are by default global, which means they can be shared by different formulas in the same report. A local variable is used only in a single formula, and there is another kind (forget the name) that is shared among the container report and sub reports. <p>Malcolm Wynden<br><a href=mailto:wynden@island.dot.net>wynden@island.dot.net</a><br><a href= > </a><br>
 
Thanks for that guys, however how do I declare a global variable? Can I get an example of declaring a variable in a section that would be great. Do I associate it with a section format event?
 
Sorry I did not add that I am using VB 6 and SQL 7
 
Guys, i have figured out how to do this now.<br>I created a formula field in the report page header section<br>and assigned it so:<br>WhilePrintingRecords;<br>&nbsp;&nbsp;&nbsp;&nbsp;numberVar iRecordNumber:= 0;<br><br>then in the details section, in the color tab, i added&nbsp;&nbsp;a formual to the background colour, like so:<br>iRecordNumber:=iRecordNumber + 1;<br>if remainder(iRecordNumber, 2)= 0 or (recordnumber = 1) then<br>&nbsp;&nbsp;&nbsp;&nbsp;Color(210,210,210)<br>else <br>&nbsp;&nbsp;&nbsp;&nbsp;White<br><br><br>thanks for your help :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top