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

Totals and percentages fields in a stats report

Status
Not open for further replies.

ukusa

Programmer
Oct 8, 2001
49
AU
Howdy all,

I'm doing up the finishing touches to a Psychosocial Assessment tool and trying to get the stats report to work.

After entering a criteria of some sort on one of my screens, the system goes through and searches for matches and counts up the figures, then dumps them in a table. Being new to report statistics - it is driving me nuts.

The fields are integers.

If for example I lay out:

Hallu Narc Alco Sed Hypn Total
Wkly 7 2 19 1 3 Expre field
Mnthly 4 8 11 2 5 Expre field
Total Exprn fields along here
Percent Exprn fields along here

When I use an expression field for the "total" and "%",
it works when I preview the report, but when I run it, it
gives an invalid function message and so on.

In the Expression field dialog, I put:

table1.Hallu+table1.Narc+table1.Alco...

Am I doing this wrong? Even if I just do "hallu+Narc+alco" and preview it, it works but not in runtime.

Could someone please tell me how to put in totals that work without pre-totalling outside the report? Thanks

Allen
PS using Delphi 5 Professional and the latest QReport components.
 
When you say preview, do you mean previewed within the IDE without actually running your program? or do you mean you have a 'preview' button in your program?

If you're talking preview button, then I'm at a loss.

However if you're looking at it within the IDE, then I'd be looking at making sure Table1 is still open and available, and got the correct records etc. by the time you try to print the report.
 
Sorry, should have explained that. Looking at it in IDE preview or development mode, it works great. It's when the program is running that it fails and the data comes up correctly from table1 but the calculation fields give me all sorts of errors... like unknown function and so on... in the running programs report preview.

 
What sort of testing have you done so far? Does every report field with an expression fail? Try temporarily changing one of your expressions to something simple like 1+1. If that fails then something screwy is going on. Perhaps your syntax is wrong. Try and break it down to determine exactly what is causing the unknown function. Is it causing an exception? Or is the report simply showing error messages within the fields?
 
Thanks Griffyn, I'm testing away - I'm getting bizarre results her... thanks for that!
 
Ok, found a solution! Struth! Anyway, It came down to that I'm using 2 tables to create the one report (it's a big stats report!) and am using sub-detail bands to make the extra pages in the report instead of using composite. Since stats are in a particular order, there is a mixture of table2 and table1 data in the same band on some pages. I had to give the report itself the "datasource of table1" and put the bands "dataset to table2" - this works without a hitch - no strange results even though the majority of the data there is table 1 stuff. Why this works like this I'm not quite sure, but if anyone has any ideas...

If this is a quirk with Qreports, then I'll have to remember what I have done if a further Qreport update has fixed this!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top