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

Ranking records - simple formula

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I'm new to Crystal Reports and what I want should be fairly easy, but I can't seem to print out a simple count on each detail line.

For instance, if I have 18 records returned, I want a #1 placed on the first detail line (as Rank #1), #2 placed on the second detail line, up to the total count for the records.

i.e.
#1 Customer1
#2 Customer2
#3 Customer3
...
#18 Customer18

A simple For Loop should do it, but my looping is giving me the total (18) on each line, it's not counting properly.

TIA,
Karen
(CR8.5)
 
Create a fomula field and name it counter. add the following code...

WhileReadingRecords;
NumberVar Counter := Counter + 1



Add the formula to your detail line
 
Karen,

Your welcome. I had actually meant to say WhilePrintingRecords but both seem to work ok. Also, it may be good practice to initialize the counter. You can do this by creating a new formula named InitializeCounter and add the following code...

WhilePrintingRecords;
NumberVar Counter := 0;

Add this formula to the Report Header and then suppress the field.

You can also put InitializeCounter in a Group Header to reset your counter for each new group.

Jase
 
Jase,

I don't think there is a need to create a separate formula to initialize the variables in CR. I never have, and my variables seem to work. I think they always initialize themselves at the default value for the data type.

However, I have seen several people do this and so if you or anyone knows why, please share. Ken Hamady
On-site custom Crystal Reports Training and Consulting.
Quick Reference Guide to using Crystal in VB.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top