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!

Row numbering formula not working

Status
Not open for further replies.

Tichaona

Technical User
Dec 17, 2023
2
BW
Hi,

I have a crystal report formula for row numbering that doesnt seem to work. Just repeats 001 on all rows.

NumberVar rowNum;
If OnFirstRecord or {Invoice Number Field} <> Previous({Invoice Number Field}) then
rowNum := 0;
rowNum := rowNum + 1;
Right('000' + toText(rowNum, 0, ''), 3)

Screenshot_2023-12-17_090700_oc4ntj.png
 
Remove the line:
"rowNum := 0;"

As it is currently, you are setting the variable to 0, then adding 1 for every line, hence the result is 1 for every line.
 
A variable is not needed for this, just use the special field RecordNumber.

Right("000"&ToText(RecordNumber,0,""),3)

If you don't need the leading zeros, no formula is needed at all, just drag RecordNumber on to the desired place on your report canvas.

Macola and SAP Business One Consultant
Check out our Macola tools:
 
I have details a and details b, so want it to work for both
 
Your formula should being with:

Whileprintingrecords;

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top