Breaking News
recent

Counting the number of rows in Delphi and Rave Reports

Display the count of the number of rows for a particular table in Rave Repot



Solution 1:
This can be done quite easily using a CalcText component by setting the CalcType to ctCount, the Controller so that it points to the databand and then setting the RunningTotal to true. 

Solution 2:
Drop down a regular text component on your band. Click on it and then click on the Event Editor tab. Select OnBeforeReport from the Available Events combobox. Now click in the edit area below the Compile button and type in the following code:

self.Text := '';

This will clear whatever text has been placed in the text component at design time. Now select the OnGetText event from the Available Events combobox and type in the following code:

if Value = '' then Value := '1'; self.Text := Value; else Value := IntToStr(StrToInt(Value) + 1); self.Text := Value; end if;

Now click on the compile button and assuming that you have typed it in correctly you will get a message that it compiled successfully. You can now run the report and it will display the line number as specified.

It should be noted that in the description of the OnGetText event there is a note that indicates that you should not assign anything to the text property from within this event. Normally this is true. You would not want to do this because it will have no effect on the output for this instance of the OnGetText event. It will have no effect because the text value has already been read and stored in the "value" variable and this is what is used when the component prints. However, in this instance we are using the text property to store the current line number, which we then use and increment on the next pass.


K-Smart

K-Smart

No comments:

Post a Comment

Please leave you comment to improve our services and support

Powered by Blogger.