Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Show number as 001 (incremental) Post Reply Post New Topic
Author Message
Kwirky
Newbie
Newbie
Avatar

Joined: 21 Apr 2010
Online Status: Offline
Posts: 32
Quote Kwirky Replybullet Topic: Show number as 001 (incremental)
     Posted: 26 Jun 2011 at 6:37pm
Hi,
I am trying to produce box labels which have a string that needs to end in numbers like 001, 002, 003 etc to a maximum which is equal to the total number of boxes.
I tried using record number however this displays as 1, 2, 3, 4 etc.
How can I get the record number to format the way I need?
For example I have an order with 16 boxes; the order number will be something like ABC606806 so I will need the boxes to be
ABC606806001
ABC606806002
ABC606806003
all the way to
ABC606806015
ABC606806016

The number of boxes per order will vary from 1 to as many as we need.
I would like to calculate to 999 (so the label would be ABC606806999).

We are using CR2008
IP IP Logged
Keikoku
Senior Member
Senior Member


Joined: 01 Dec 2010
Online Status: Offline
Posts: 386
Quote Keikoku Replybullet Posted: 27 Jun 2011 at 2:43am
Here is an example of how you would use recordnumber in string concatentation:


"Entry#" + CStr(recordnumber, 0)


You will have to figure out how to get those zeroes on the left of the number.

Two options off the top of my head:

1: figure out how many digits there are in recordnumber and then say

"yourStr" + numZeroes + recordNum.

Requires some calculations, but it shouldn't be too difficult since they are 3 digits maximum.

2: figure out how to pad the number (in string format) with zeroes, then join it to "YourStr"

EDIT: on second thought, the two ideas are pretty much the same thing.

Edited by Keikoku - 27 Jun 2011 at 3:11am
IP IP Logged
Kwirky
Newbie
Newbie
Avatar

Joined: 21 Apr 2010
Online Status: Offline
Posts: 32
Quote Kwirky Replybullet Posted: 27 Jun 2011 at 11:39am
Thanks so much for youe help.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 27 Jun 2011 at 11:55am

you can use

cstr(recordnumber, "000")
to insert the lead zerosĀ 
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum