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

How to pass a value fron subreport to main report

Status
Not open for further replies.

siddu1234

Programmer
May 21, 2008
5
US
Hi
I am creating a crystal report with main report and sub report.It will basically record user transactions along with login details.
There are two groups in main report
The main report layout is something like this.

Group 1 (UserID)
Group 2 (UserLoginID)(UserLogin table with UserID as foreign key)
Subreport (show all inoutLog for a particular UserLoginID from INOUTLOG table which is having USERLOGID as foreign key.Also calculates Total time logged In and total time logged Out as summary of all inoutlog records corresponding to USERLOG_ID)
Details (Transactions in that login)
Transaction 1
Transaction 2
------- records
Group 2 footer
Group 1 Footer
Summary by user( Crosstab (Row as UserName and column as the zone and no of transaction as sum field)
Report Footer
GrandSumary(same row, column, sum fields which list all users)

Here in the above layout in the sub report section i have a variable which calculates the totaltimeIn and TotalTimeOut for a specific USERLOG_ID(group 2 level).
I need to get this values to my main report from subreport and calculate the totaltimein and totaltimeout at
Userlevel(Group 1 level).So that i can show that as a summary along with crosstab shown at group 1 level something like this
TotalTimeIn 20 minutes
TotalTimeOut 2 minutes
and also i need to get these total at report grand summary level ie, report footer for each user.Please
let me know how to achieve this ?
 
In the subreport, create shared variables that are placed in the sub report footer:

whileprintingrecords;
shared numbervar timein := sum({@yourtimeincalc});
shared numbervar timeout := sum({@yourtimeoutcalc});

Then in the main report group #2 footer, use a reset formula:
//{@resetshared}:
whileprintingrecords;
shared numbervar timein := 0;
shared numbervar timeout := 0;

Insert a group #2b and then create this formula:
whileprintingrecords;
shared numbervar timein;
shared numbervar timeout;
numbervar sumtimein := sumtimein + timein;
numbervar sumtimeout := sumtimeout + timeout;

Then in the Group #1 header use this reset formula:
//{@resetgrp1}:
whileprintingrecords;
numbervar sumtimein;
numbervar sumtimeout;
if not inrepeatedgroupheader then (
sumtimein := 0;
sumtimeout := 0
);

Then in Group #1 footer, display the results:
//{@displaysumtimein}:
whileprintingrecords;
numbervar sumtimein;

//{@displaysumtimeout}:
whileprintingrecords;
numbervar sumtimeout;

For the report footer, the simplest solution would be to insert the subreport again, this time not linking it, but grouping on userID and displaying only the summaries per group.

-LB


 
Hi,
Thanks.I am able to get the DisplaySumTimeIn and DisplayTimeOut formula values correctly.I need a small help again.How can i hide the display of values of certain formulas in the report which are not required to display?
For example in the above Main Report the formula's like @resetgrp1, sumShared(group 2b) will display 0.00 value in the report at the specific level even though they just reset and sum some variables ?How to hide 0.00 but still the placing the formulas in the report in group1 header and group2b ?
 
Just right click on them and suppress them.

-LB
 
Hi,
Thanks.I need a small help once again.In the above report i have transaction records which are grouped by UserID and USERLOGID as mentioned above.Under UserLog group the transaction record rows will show these columns

TRANSACTIONSTART LOGINTIME LOGOUTTIME NO
2/3/2008 5:00AM 2/3/2008 4:50AM 2/3/2008 5:30AM 1
2/3/2008 5:15AM 2/3/2008 4:50AM 2/3/2008 5:30AM 2

Here i need to find the difference between first transaction starttime and logintime(5:00 - 4:50) at USERLOG group level.
How can we do using a formula.I tried onfirstrecord , but i find that it will take one first record not first record in each USERLOG group.How can we do at group level?
 
You should be able to use a formula like this:

if {table.transactionstart} = minimum({table.transationstart},{table.userlog}) then
datediff("n",{table.logintime},{table.transationstart})

You can place this formula in the detail or in the group header and it should be correct, as long as you are sorting ascending by transactionstart.

Note that you should start a new thread when you have a new topic.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top