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

Passing data from unlinked subreport to Main Report

Status
Not open for further replies.

michellecole

Programmer
Feb 12, 2004
42
0
0
US
Crystal 8
Microsoft Access

I have a Main report displaying CustomerIDs. For each CustomerID there are (3) unlinked subreports - one is displaying AccountIDs, one is displaying SiteIDs and one is displaying ScannerIDs. I would like to have a grand total at the bottom of the Main report reflecting a count of total AccountIDs from the AccountID subforms. I have been reading other posts and have confused myself on the best approach to accomplish this. I believe I want to go the "Shared Variable" route, but I am unsure of what and where I need to code things.

Here is a skeleton of my "Customer" report:

RH
PH
Da tblCustomers.CustomerID
CustomerSubReport_Accounts
Db CustomerSubReport_Sites
Dc CustomerSubReport_Scanners
RF
PF

I have read a lot about text fields and formula fields and WhilePrintingRecords - but I don't know if I should be creating "Formula Fields" and if so, what is the formula syntax and where should the formula fields go? Do I have to DIM a Shared Variable. Feel free to start a duh for me on this one.

Your help is greatly appreciated!

Thank you,
Michelle
 
You have unlinked subreports in the detail section?

So since they are unlinked, you get X number of executions of each subreport for every customer, and they're all identical to each other?

I won't get any more into that, but this seems very odd.

To pass the total count of every execution of the subreport back to the main report so that you can provide a single grand total, create a shared variable in the subreport such as:


subreport formula:
whileprintingrecords;
shared numbervar AcctIDCount;
AcctIDCount:=AcctIDCount + count({table.acctid})

Then you can display this in the report footer (saying that you want it at the bottom of the report isn't specific, you show your sections in the example and then not use it as a reference for where things go).

Main report formula in the report footer:
whileprintingrecords;
shared numbervar AcctIDCount

I would suggest that you try to be methodical about describing requirements, such as displaying where things are, and where you want things.

Again, having unlinked subreports in the details is very inefficient, and it is very strange unless you want the exact same results in every details section.

-k

-k
 
Thank you for your response - it worked! I was missing the syntax in bold. Please forgive me - the subreports are indeed linked via CustomerID - I was thinking linked meant something else so I went and looked up what it meant.

subreport formula:
whileprintingrecords;
shared numbervar AcctIDCount;
AcctIDCount:=AcctIDCount + count({table.acctid})

Main report formula in the report footer:
whileprintingrecords;
shared numbervar AcctIDCount


I would suggest that you try to be methodical about describing requirements, such as displaying where things are, and where you want things....

Ouch! I saw other threads get beat up over this too and I thought I was doing such a great job posting - I'll try harder next time! Fortunately we were successful!

Thanks again,
Michelle



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top