variables / aggregates
Hi,
I'm sorry, this must be simple, but I'm unable to find out how to use aggregates in a header band...
I'm following the intructions in the manual (double pass & OnBeforePrint events with Get/Set)
So far I was't able to use my own declared variables eg <Group."Total"> & <Group."StartDate">
I do get errors as "could not convert variant of type (null) into type (OleStr). Unknown variable or datafield: Group."Total"
Set(<Group."Total">, SUM(...));
The variable does however exists...
I also noticed that you get another error when you haven't set an expression in your variable.
Finally I just used a datafield (as shown in the manual) and this works. At least for my totals.
Is this normal?? How can I use custom variables?
Further, how do I format a date variable ? Set(<Customers."CUSTOMER_DATE">, MIN(<Customers."INVOICE_DATE">, masterdetail1)
If I want to use this as Memo1.Text := 'Month : '+FormatDateTime('mmmm', Get(<Customers."CUSTOMER_DATE">). But this doesn't work. I get errors on this
Last question:
Is there a way to fill in variables and just use these inside a text object of the report gui? Do you realy need to use the code as in memo1.txt?
Thanks in advance,
I'm sorry, this must be simple, but I'm unable to find out how to use aggregates in a header band...
I'm following the intructions in the manual (double pass & OnBeforePrint events with Get/Set)
So far I was't able to use my own declared variables eg <Group."Total"> & <Group."StartDate">
I do get errors as "could not convert variant of type (null) into type (OleStr). Unknown variable or datafield: Group."Total"
Set(<Group."Total">, SUM(...));
The variable does however exists...
I also noticed that you get another error when you haven't set an expression in your variable.
Finally I just used a datafield (as shown in the manual) and this works. At least for my totals.
Is this normal?? How can I use custom variables?
Further, how do I format a date variable ? Set(<Customers."CUSTOMER_DATE">, MIN(<Customers."INVOICE_DATE">, masterdetail1)
If I want to use this as Memo1.Text := 'Month : '+FormatDateTime('mmmm', Get(<Customers."CUSTOMER_DATE">). But this doesn't work. I get errors on this
Last question:
Is there a way to fill in variables and just use these inside a text object of the report gui? Do you realy need to use the code as in memo1.txt?
Thanks in advance,
Comments
For the first kind you use Get() and Set()
Look at this thread which deals with a similar problem.
http://www.fast-report.com/en/forum/?p=/discussion/9134
These variables can be referred to like table columns.
The second kind you use like ordinary Pascal variable. However, they are run-time only as far as I can figure out one can only assign them to a memo component or a categorized variable in the script.
Thanks, but I found this thread already, but unfortunately I can't get it right... where is SaldoAtual in this case declared? As a variable in the script? Or as a variable in the report?
I tried this as well, but I seem to be unable to get it right in case with dates :-(.
Anybody an idea how I can get a date 'variable' formatted into a header?
Something like Memo1.Text := 'Month : '+FormatDateTime('mmmm', Get(<Customers."CUSTOMER_DATE">)
Put three (in)visible text objects in the footer of the report with the following text:
MIN(<Customer."CONSULT_DATE">,MasterData1)
and
MAX(<Customer."CONSULT_DATE">,MasterData1)
and
[SUM(<Customer."FEE">,MasterData1)]
Than use the following script code:
Thank you. It was very useful for me.
I have three nested groups and need to show an average score (from the detail section) for each group in their respective headers. I cannot use AVG() as not all the detail scores are available so I need to count them, sum then and do the average programatically at the end of each group.
I messed around all day today trying to apply the example in the manual and the demo to my situation and could only get the outer group to behave properly.
I can see that your solution using lists will do the job.
Thanks for posting the solution. Too many people end a thread saying "I've fixed it now" without saying how!
Howard