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!

Counting, Summarizing & Sorting 1

Status
Not open for further replies.
Jun 16, 2000
199
US
I am drawing a complete blank and need some assistance with how to get these results:<br><br>(results)<br>2 have medical, 1 has dental, and 1 has both <br><br>(example)<br>Name: Benefit:<br><br>Andy&nbsp;&nbsp;Medical<br>Bill&nbsp;&nbsp;Medical<br>Bill&nbsp;&nbsp;Dental<br>Chad&nbsp;&nbsp;Medical<br>Dave&nbsp;&nbsp;Dental<br>
 
One way to do this...<br>First, create a group by Name<br>In the Header section of the Name Group, put a formula like<br>WhilePrintingRecords ;<br>BooleanVar HasMedical := False;<br>BooleanVar HasDental False;<br><br>In the detail section, put a formula like<br>WhilePrintingRecords ;<br>BooleanVar HasMedical ;<br>BooleanVar HasDental ;<br>If {Plan} = 'Medical' then<br>&nbsp;&nbsp;HasMedical := True<br>Else If {Plan} = 'Dental' then<br>&nbsp;&nbsp;HasMedical := True<br>Else<br>&nbsp;&nbsp;False<br><br>In the Footer section of the Name group, put a formula like<br>WhilePrintingRecords ;<br>BooleanVar HasMedical ;<br>BooleanVar HasDental ;<br>NumberVar MedicalCount ;<br>NumberVar DentalCount ;<br>NumberVar BothCount ;<br>If HasMedical and HasDental then<br>&nbsp;&nbsp;BothCount := BothCount + 1<br>Else If HasMedical then<br>&nbsp;&nbsp;MedicalCount := MedicalCount + 1<br>Else If HasDental then<br>&nbsp;&nbsp;DentalCount := DentalCount + 1<br>Else<br>&nbsp;&nbsp;0<br><br>In the Report footer, put a formula like the following, which is more complex because of the subject of the verb in the text can be either singular or plural, and hey - we can't have subject verb errors in the report, can we. (The truth is I'm avoiding doing my quarterly tax return I guess)<br>WhilePrintingRecords ;<br>NumberVar MedicalCount ;<br>NumberVar DentalCount ;<br>NumberVar BothCount ;<br>StringVar PlanSummary ;<br>If MedicalCount = 1 then<br>&nbsp;&nbsp;PlanSummary := '1 has medical, '<br>Else<br>&nbsp;&nbsp;PlanSummary := ToText(MedicalCount,0) + ' have medical, ' ;<br>If DentalCount = 1 then<br>&nbsp;&nbsp;PlanSummary := PlanSummary + '1 has dental, '<br>Else<br>&nbsp;&nbsp;PlanSummary := PlanSummary + ToText(DentalCount,0) + ' have dental, ' ;<br>If BothCount = 1 then<br>&nbsp;&nbsp;PlanSummary := PlanSummary + '1 has both.'<br>Else<br>&nbsp;&nbsp;PlanSummary := PlanSummary + ToText(BothCount,0) + ' have both.' ;<br>PlanSummary<br> <p>Malcolm Wynden<br><a href=mailto:wynden@island.dot.net>wynden@island.dot.net</a><br><a href= > </a><br>
 
Thanks. <br><br>There are some questions that I have with understanding the info you wrote. (BTW...I did figure this out a different way by including many different arithmetic formulas) but...if you have time, I would like some clarification in understanding your idea. (I am not all that familiar with variable declarations & would appreciate any assistance)<br><br>The only thing that I really don't understand clearly is the header section group formula. Is this where you are declaring the variables hasmedical and hasdental & why are you declaring it this way?
 
Variables need to be declared prior to their use in a formula.&nbsp;&nbsp;Unless otherwise specified, variables are global in scope, but this means only that their values are global - you still have to declare a variable in each formula that you want to use it.<br>The assignment of values to variables is what is happening in the header section.<br>WhilePrintingRecords ;<br>BooleanVar HasMedical := False;<br>BooleanVar HasDental := False;<br>What this does is assigns the value false to these variables everytime this group header prints.&nbsp;&nbsp;The assignment operator := is not the same as the equality operator.<br>Variables are a very useful tool, and worth the effort in learning how to use them. <p>Malcolm Wynden<br><a href=mailto:wynden@island.dot.net>wynden@island.dot.net</a><br><a href= > </a><br>
 
Hi MalcolmW,<br>&nbsp;&nbsp;&nbsp;I was having a similar problem as this one and knew the answer was out here somewhere.&nbsp;&nbsp;Just wanted to say thanks and maybe you should put this one out on FAQ. <p>LindaC<br><a href=mailto:lcastner@co.orange.ny.us>lcastner@co.orange.ny.us</a><br><a href= > </a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top