Is it possible to change the title of a report in code using delphi code
I am struggling to change the title of a report which can be executed after different sql commands have been executed to filter the data that the report will show
For example - select * from coachdata order by surname
I would like this printout to have the title 'All Coaches - Alphabetic'
Using the same report and filtering by postcode i.e.
select * from coachdata where postcode is NULL
I would like this printout to have the Title Missing Postcodes
There are about 20 different combinations of the report.
Obviously I do not want to use 20 separate frxReport components to achieve my goal
I have searched all of the usual info sites and the only reference I can find is to build the report on the fly in code and not use the built in designer - again not an ideal situation
Any Help much appreciated
Bob Wallace
Comments
G'day Bob,
I am not sure where you want to use the Title, but if you are like us you probably want to see it:
We do this for our major App's Reports prefixing the "Title" with the Financial Year number and suffixing some of them with User selection information (e.g. "Settled", "Unposted").
To achieve this, the first Property to set is your Report's (TfrxReport Component) "Filename".
This will possibly be enough for you. If I understand your question correctly, the changes need to be made after the SQL is set up for the Query, so you probably need to set Filename in the OnBeginDoc Event Handler.
Hope this is helpful...
Cheers, Paul
Use in the report's script (free FR Embarcadero edition doesn't have script support):
procedure Page1OnBeforePrint(Sender: TfrxComponent);
begin
if MasterData1.DataSetName = 'MissingPostCodes' then Memo1.Text :=' Missing Post Codes'
else if MasterData1.DataSetName = 'AllData' then Memo1.Text :='All Coaches Alphabetic';
end;
Create a text object place holder on the report named ReportTitle. Set it's Text property to 'Report Title'.
In your app, use TfrxReport.FindObject to locate ReportTitle and then cast and set the objects Text property if it has one.
You'll have to convert this to Delphi: