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

How to get the Total of each user and then all users 1

Status
Not open for further replies.

ttechie

Technical User
Feb 11, 2005
56
IN
I have CR 10. I will try my best to explain by question. I am working on a report that gets data from sql and counts the number of lines. I count the user lines Individually. But I need to count grand total of each user and also in the end grand Total of all the users. . Here is my code:

shared numberVar RowsThisRecord;
shared numberVar GrandTotalRows;
stringVar Result := '';
numberVar RowCount := int((len({MEDICAL_REPORT_OBJECT.MRO_TEXT}) / 65)+ 0.99);
RowsThisRecord := RowCount;
GrandTotalRows := GrandTotalRows + RowsThisRecord;
UserTotalRows := UserTotalRows + RowsThisRecord;
numberVar i;
for i := 1 to RowCount do
(
Result := Result + mid({MEDICAL_REPORT_OBJECT.MRO_TEXT},(i*65) - 64, 70) + chr(10);
);
"Lines Recorded: " & RowCount & chr(13) & Result;
 
Why isn't the grand total just a summary (count) of the number of records?
 
It only gives 0.00. for some reason.
Thanks!
 
I don't mean why isn't your formula giving the correct answer.

I mean why are you creating a formula for grand totals at all. Why isn't 'Insert>Summary' good enough?
 
Good question. When I use 'Insert>Summary is doesn't gives my the option to select my formula. in this case @Lines. Also, If you can tell me how to fixed below I am suppose to have
Lines Recorded: 19 AND Grand Total 934. But I get
Lines Recorded: 19.008,934.00
Any Ideas?
 
Hey! Lupin46,I got the count thing working at last. Thanks! Can you tell on how to get data from certain dates in crystal. for ex from 11/04/05 to 11/14/05.??
Thanks!
 
Assuming these are dates specified by the user, you would create parameter fields for the start date and end date. Then use these parameter fields in the record selection expert (or create the code in the record selection formula directly).

 
Actually, I want days between two weeks for ex 11/05 through 11/14. Is there a way to when the user just click on date and it should give two week report. The end user don't have to specifiy the date. In parameter fields, what should I pick and where save it. Is there a query or formula that I can use?
Thanks
 
Shared variables are needed for passing things back from subreports to the main report. Ordinary variables are one way to accumulate totals, but running totals are easier.

For a date range, say something like {your.date} in [@param_start to @param_end]. With running totals, you can write the tests as formula fields, display them with the data and then test for them in a running total once you are sure they are right.

Right-click on a field and choose Insert to get a choice of Running Total or Summary. Or else use the Field Explorer, the icon that is a grid-like box, to add running totals.

Running totals allow you to do clever things with grouping and formulas. They also accumulate for each line, hence the name. The disadvantage is that they are working out at the same time as the Crystal report formats the line. You cannot test for their values until after the details have been printed. You can show them in the group footer but not the group header, where they will be zero if you are resetting them for each group.

Summary totals are cruder, but are based directly on the data. This means that they can be shown in the header. They can also be used to sort groups, or to suppress them. Suppress a group if it has less than three members, say. They default to 'Grand Total', but also can be for a group.

Variables are user-defined fields. One useful variant are shared variables to pass data from a subreport back to the main report. You can also use variables to show page totals. For normal counting I find running totals or summary totals much easier.


[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top