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!

Sub Report (get Main field value)

Status
Not open for further replies.

maecode

Programmer
Oct 22, 2003
6
SG
Hi! I have a subreport1 in crystal report link to the same dataset. How can I get the field value in the main report?

eg.
I have a field display "ID" in the Main report.
In my sub report, I want to get the ID.
So, my formula in subreport will be

@Contact:
If {ID- from main report} = ID - from sub report then
formula = {table1.contact}

Please help.
thanks
 
In Crystal 8.5, the subreport link is on the menu under [Edit]. When you make a link, it may add something to your selection formula in the subreport. This can be removed and replaced by whatever you want.

Madawc Williams
East Anglia, Great Britain
 
or if you don't want your subreport linked by this value that you want....create a Shared value in the main report and also in the subreport...this way the value can be passed from Main report to subreport

Using your example:

In the main report...in a section BEFORE the section containing the subreport place this formula

//@AssignSharedVariable

WhilePrintingRecords;
shared stringVar Field_ID := {TableMain.ID};

then in the subreport place this formula anywhere


//@Contact

WhilePrintingRecords;
shared stringVar Field_ID;
StirngVar result := "";

If Field_ID = {TableSub.ID} then
result := {table1.contact};

result;

that will do it.


Jim Broadbent

The quality of the answer is directly proportional to the quality of the problem statement!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top