Link to home
Start Free TrialLog in
Avatar of Yeturi
Yeturi

asked on

Crystal Reports - Formulas in detail section

Hi,

I have a gloabal variable x declared in a formula. I increment that field by 10.

My requirement is like below: I want to place the same formula in Page header and Detailed section. data in detailed section is not being repeated as I used the same formula.
Requirement:
Page header:
Display Value of x as 10.

Detail section: display as below.
20
30
40

Displaying as:
Page header:
10

Details Section:
20
20
20


Could you please help me how can I get the value in formula to increment when placed in detailed section?

Thanks,
Yeturi.
Avatar of DustinKikuchi
DustinKikuchi
Flag of United States of America image

Your formula should look something like:

Shared NumberVar x := x + 10;
x;

This will increment x by 10 and then display the new value of x.
Avatar of Yeturi
Yeturi

ASKER

I did the same.

WhilePrintingRecords;
Shared numbervar count1;
count1 := count1 + 10;

I placed the formula variable two times in the Detailed section as below:

@Numdisp
@Numdisp

The output displayed as
10
10

I am expecting
10
20
ASKER CERTIFIED SOLUTION
Avatar of Mike McCracken
Mike McCracken

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Yeturi

ASKER

Is there is any way, that within the same details section I can use one formula?

My requirement is like I cant have multiple detailed sections ans I need output like

10
20
30

Or else is there is any way, that I can have a counter that can be incremented in the same detailed section in a formula?
You may need to use the WhileReadingRecords evaluation runtime in order to have the formula properly increment within the detail section.
Avatar of Yeturi

ASKER

WhileReadingRecords;
Global numbervar count1;
count1 := count1 + 1;

I have rewritten the formula as above. But changed count1 from Shared to Global as it said Reading cant be with Shared.

But it dint work.. give as same..

10
10
Shared is intended for use with a subreport.  Global is for use within a single report.

Since subreports evaluate in the Printing Pass through the report shared variables are only valid in that pass.

I have never had a reason to update a variable as you want so I don't know if there is a way to do it.

What is the reason for doing this?

mlmcc
Avatar of Yeturi

ASKER

In my details section, I have a requirement like I need to have the label to increment with alphabets. I thought to use a sigle formula as I dont know in each details section how many times I will require the below.

So I have taken an array and trying to increment the counter by 1 but I am repeting the formula in teh same detailed section its not being incremented.

Is there is any way to acheive it?

like,

a
b
c
d
e
and so on..
The detail section only works on 1 record at a time.
DO you have a field you are trying to split into several lines each of which needs a "label"

mlmcc
Avatar of Yeturi

ASKER

Not sure of the question you are asking..

I have some 10 details section in the report. I will supress and enable the detailed sections based on the logic. not all the detailed sections will be invoked everytime.
The exact requirement is,, In the below, the labels for a,b,c,d,e,f,g,.. should be dynamically enabled.

Like If the logic says to display section 1 and 3 then section1 should show labels as a,b and section 3 should show as c, d.
if the logic say to display section 2,3 then labels should be as a,b,c in section 2 and d,e in section3.

Hope this is clear now. Is there is any way to acheive it?

Detailed section1:
Name           a       Datavalue
Empnum      b       Datavalue


Detailed section2:
State          c       Datavalue
Depnum    d       Datavalue
Depname  e      DataValue


Dtailed section3:
sal       f     Datavalue
Comm g    Datavalue
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial