Link to home
Start Free TrialLog in
Avatar of chkueh
chkuehFlag for Singapore

asked on

How to share data at main report and sub report, Crystal Report 10?

Hi, Experts
I would like to share some information located at main report with sub report. For example, in main report have quantity, so in my sub report the quantity will be used for some calculation.

How can it be share in sub report or any other ways for me to get the quantity data?

Thank you in advanced....
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 chkueh

ASKER

Hi,

any guide for me to follow? i not really expert in crystal report...thanks
Avatar of Mike McCracken
Mike McCracken

Not really.  Just follow the seps I outlined.

To create a new formula right click FORMULAs in the Field Explorer
Click NEW
Give it a name
Enter as shown
Save
Drag to report like any other field

mlmcc
Avatar of chkueh

ASKER

Hi, mlmcc...

i had create the formula at main report with this formula...---formula = {table1.Qty}--

what should i do at sub report? thank you.
Okay, another way to do this is to add the field to the subreport links.

(Right click the subreport, change subreport links, add the field(s) you're interested in, but untick the bit where it says "select data in subreport based on field")

This will give you a parameter in the subreport which will contain the data from that field at the time the subreport is called. {?Pm-table1.qty} use that in the calculations.
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
Avatar of chkueh

ASKER

Hi, Experts

This is what i need in my report(as attached image).

Hi, PCllain...
When i insert the formula at Formula workshop - formula editor, i get an error such as:-
(i) The remaining text does not appear to be part of the formula
(ii) the special variable 'Formula' must be assigned a value within the formula.

is that different version of crystal report using different formula writing or i insert the wrong code?

Thank you very much.
Regards,
chkueh


concept.JPG
Can you show the formula.

You should be writing 3 separate formulas

mlmcc
Avatar of chkueh

ASKER

Hi,

at main report, i create BatchSize formula fields with below formula:-
Formula = {Table1.Qty}

then, i create again another formula field shared_BatchSize is fr me to share BatchSize in my sub report, but i get an error, (A variable name is expected here.)

then i try another formula:-
whileprintingrecords;
shared NumberVar BatchSize;
BatchSize={@BatchSize}

How can i get it for my sub report?

Thank you.


ASKER CERTIFIED 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
Avatar of chkueh

ASKER

Hi, PCllain...
thank you for you guide...i never notice the different before for the crystal & basic syntax. Your code work 100%....but 1 problem is the share @BatchSize field at main report must drag to any part of the report, if not the value that i get in sub report will be "0". Now i drag it to any part of the report & hide it...

another question, at sub report how can i suppress the shared field that has been drag into sub report? all other fields will automatic suppress  when no record but the shared field always displayed.

thank you...
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