Do math between a report and subreport

Can I do math on values in a report added to values in a subreport?

Heres an example of what I have now:

                                          (sub Rpt column)

Client,             Commissions,   (Demo)

Frank Stevens,  100.00 ,          (20.00)
Jeff Smith,        250.00,           (10.00)
Jane Doe,         500.00             (       )

Totals              850.00                              <<main report footer

How can i put the (demo) total at the bottom of the main report, and add commissions to (Demo) and display as a column.

E.G.
                                         (sub Rpt column)

Client,             Commissions,   (Demo)

Frank Stevens,  100.00 ,          (20.00)     120.00
Jeff Smith,        250.00,           (10.00)     260.00
Jane Doe          500.00            (        )     500.00

Totals              850.00              30.00      880.00

Any help would be greatly appreciated, thanks.

NDSgroupAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

SimonLarsenCommented:
putting a field in the footer with Sum([Demo]) doesn't work?

If you look at the properties of the existing sum of commissions and modify it accordingly you ought to be fine.
0
harfangCommented:
If curComm and curDemo are currency fields in the table, it is easy:
* Add a new text box for the next column with "= curComm + curDemo" as control source
* Create a report footer on the subreport and ...
* Add a new text box for the demo total with "= Sum(curDemo)"   <--- txtSumDemo
* Add a new text box for the TOTAL with "= Sum(curComm + curDemo)"   <--- txtSumCommDemo

Now, for a reason not entirely clear to us, you want to show the total in the main report, not as a footer of the subreport...
* Add a text box on the main report with "= subSubReportName!txtSumDemo"
* Add a text box on the main report with "= subSubReportName!txtSumCommDemo"

Note: the name "subSubReportName" is the name of the subreport *control* not necessarily the name of the subreport.
Note: you can naturally hide the subreport's footer when you are done debugging.
Note: For the calculation of curComm + curDemo, you could do this in the query on which the report is based.

So, "Can I do math on values in a report added to values in a subreport?"
Not really, but the main report has access to all controls of the subform, containing the last usage of each section.


Good luck with your project!
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
firebird-scCommented:
If what they have suggested doesn't work, consider reworking your report layout. If there is basically a 1-to-1 relationship between the two recordsets (i.e. if for each client record there is only one demo record), then you should be able to create a single query which contains all of the data that you need. Then you can redo your report so that there are no sub-reports to complicate matters.

If there are more than one demo record per client record, you can still probably set things up in this way, but it gets a little more tricky. You would have to design a query which first sums up the Demo values for each client, then create a second query which combines the rest of the fields with the summed Demo data.  Queries like these are not my forte (yet), however, I have designed many reports with subreports and so on, and am slowly discovering that report design is a whole lot easier if you can possibly set up the queries to provide you with a single recordset.

 
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

harfangCommented:
> report design is a whole lot easier if you can possibly set up the queries to provide you with a single recordset
Very true.

This works with nested information. For example (pseudo report-printing code)

for each order
   print order header
   for each order detail
      print row
   next
next

or

for each department
   for each month
      for each salesperson
         for each sale
            print row
         next
      next
   next
next

But if you have more than one internal loow, you will need subqueries, as in:

for each employee
   print employee sheet
   for each employee property
      print property
   next
   for each job change
      print job title
   next
   for each year
      print salary overview
   next
next

The question here is rather: does the subform's report footer information really need to be printed on the main report? It seems more logical and it is easier to place total fields in the same report as the data...

Cheers :)
0
NDSgroupAuthor Commented:
the reason I need to do it the way i described is as follows:


SalesReps make sales, and earn a commission on the sale.

Canvassers make demos, and earn a dollar amount if the demo becomes a sale for the SalesRep.

marketing managers can make demos, and they get a commission on any sale that he or his canvassers make a demo for.

so the marketing manager can make a commission and a demo amount if he makes the demo that becomes a sale, otherwise he just makes a commission if one of his canvassers made the demo.

the problem is that my design dosent allow for a query that will show the marketing manager, the canvasser, weather or not the marketing manager gets a demo amount, how much the sale was for, and any commissions made all on the same one.

what i did was make a report that shows all the marketing mamagers commissions on sales that he or his canvassers demoed, and then made subreports that show the demo amounts the marketing manager should get(demos(appointments) are connected to clients, not sales).  Then i placed the subreport in the detail of the main report. Then i used a text box and some code to add the demo amount to the commission amount to get a total commission on the sale using
 =[ComContract]+IIf(IsError([Demos].Report!Demo),"0",[Demos].Report!Demo)
I used the IIf(IsError part because the marketing manager wont get a demo on every client that he gets sale commissions on, so sometimes that "row" on the report wont contain anything in the subreport and the math woulld generate an #Error on the report, now if there is no info it places a 0 there instead so I can add it.

then i was able to use a copy of the above text box and make it not visible and make it keep a running sum so that i can place an =Sum in the main report footer to get a grand total.

it's a convoluted process, but it gets the job done, and the client wants the layout to be very clean:

Client,             Commissions,   (Demo)

Frank Stevens,  100.00 ,          (20.00)     120.00
Jeff Smith,        250.00,           (10.00)     260.00
Jane Doe          500.00            (        )     500.00

Totals              850.00              30.00      880.00

NOT

Client,             Commissions,   (Demo)

Frank Stevens,  100.00 ,          (20.00)     120.00
Jeff Smith,        250.00,           (10.00)     260.00
Jane Doe          500.00            (        )     500.00
                                               30.00
Totals              850.00                            880.00

the latter of the two examples is what would happen if i placed the demo total in the footer of the subreport and was just not acceptable.

So thanks for the input, I always learn something new every time I come here.

I think i have to give it to harfang because
 "Not really, but the main report has access to all controls of the subform, containing the last usage of each section."
was what sent me on the path to figuring out the math i needed.

0
harfangCommented:
Well, glad you could make it work.

As for your very  last example of layout, it just seems strange not to put *all* totals in the subreports footer. They could all be computed there, at least it looks that way. This would also work if the columns were actually in different subreports, all having the same number of rows...

Anyway, good luck!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.