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

Automatic count 1

Status
Not open for further replies.

isjorg

IS-IT--Management
Mar 20, 2007
15
BE
Hi,

I use in my group Header a formula :

//@RecordNo
WhilePrintingRecords;
Shared NumberVar RecordNo := RecordNo + 1;
RecordNo

2 things :

1) How can I give it a '01','02','03' instead of '1','2','3'

2) How can I let Crystal stop counting this records after eg. '10' lines, than at record '11' count again from '01' and stop again after eg. '20' lines, etc...

thanks for helping me

jm

 
Change your formula to the following:

whileprintingrecords;
numbervar cnt;

if cnt < 10 then
cnt := cnt + 1 else
cnt := 1;
totext(cnt,"00")

-LB

 
thanks LB,

have you also an answer on nr. 2 ?

greets
jm
 
The formula does that too. Did you try it?

-LB
 
not yet, sorry.

I thought it was just only for nr. 1

thanks for the help.

jm
 
Hi LB,

I've tryed it and it works fine, but...

is it possible that I can give 2 or 3 different counts ?

eg.: count after 10 records again starting from 1, but the second count till 9 and start again + after this 9 counts again from 1 untill 22 ??

jm

 
What is it you are trying to do? If you are trying to count based on some field, then you should be grouping on that field and inserting a count on some recurring field (or inserting a running total that resets on change of a particular field or group, if you want to see the count accumulating).

-LB
 
That is the whole problem.

I have to make a document for the government where this nothing I can use by grouping :-(

every detail contains info about different clients and the only thing why I have to do this, is because the government needs an uniform document to scan and on the first page there has to be max. 10 detail records (01 - 10) and it is obligatorily that on the second page you have to start again with nr. 01 (but here you have a new result of clients and NOT starting with the same client on page 1 !) and this untill a max. of 22 records.

I :mad: the Belgium Government !!

jm
 
Use the earlier formula (let's call it {@cnt}) in the detail section, and then go to the section expert->details->new page after->x+2 and enter:

{@cnt} = "10"

This will give you a new page after every 10 records.

-LB
 
I used it and it works perfectly, but from page 2 untill ... I need 22 records and made it like this :

if
pagenumber= 1
then
{@RecordNo} = "10"
else
{@RecordNo2} = "22"

or

if
pagenumber= 1
then
remainder(recordnumber, 10) = 0
else remainder (recordnumber, 22) = 0

for both it works for 90% perfect, only the second page is wrong.

eg.
first page =
01/02/03/04/05/06/07/08/09/10 = perfect !

second page =
11/12/13/14/15/16/17/18/19/20/21/22 = wrong !

page 3 till page 999 =

01/02/03/04/05/06/07/08/09/10/11/12/13/14/15/16/17/18/19/20/21/22 = perfect !

what is wrong with page 2?

jm
 
What is it you want? Numbers 1-10 on page 1 and Numbers 1 -22 thereafter?

Let's start over. Create two formulas:

//{@reset} to be placed in the page header:
whileprintingrecords;
numbervar cnt := 0;

//{@cnt} to be placed in the detail section:
whileprintingrecords;
numbervar cnt := cnt + 1;
totext(cnt,"00")

Then go to the section expert->details->new page after->x+2 and enter:

not onlastrecord and
(
(
pagenumber = 1 and
{@cnt} = '10'
) or
{@cnt} = '22'
)

-LB
 
PERFECT !!!

Thank you so much !

jm
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top