Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

changing label caption...

edited November 2001 in General
Hi,

I have tried in many ways, but without successs... i want to change a
caption in a report. at runtime.

Using QuickReport i can use the code Reports.QRLabel1.text:='MyText'. Easy.
But how can i do this in ReportBuilder. Is there some way?

Thank you!
Tonis.

Comments

  • edited November 2001
    Each label of the report has also a name, so just use the name of the label
    component:

    MyReportLabel.Caption := 'Your caption';
    bye

  • edited November 2001
    > Each label of the report has also a name, so just use the name of the
    label


    Thanks,

    but i have still a trouble. I know i have to try something you suggested,
    but i do not find a place where to write that. I have a report (component
    for report) ppReport1. I this report i have a caption called Label1. I want,
    that after i click on the button, label1 will get some sort of value. for
    example i have tried to use code

    ppReport1.Label1.caption:=Form1.Edit1.text;
    ppReport1Label1.caption:=Form1.Edit1.text;

    in the onclick event. But they are giving me errors that (Label1 and
    ppReport1Label) are undeclared.

    So where i have to type this code?

    Thanks a lot!

    Regards,
    Tonis.

    Easy.
  • edited November 2001
    If you are in Delphi, then the Form owns the Label1 component (see the class
    declaration of the form unit). It is visible inside the Form unit and you
    should have full control over it your OnClick event.

    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited November 2001
    As answered from e-mail:
    It indicates to me that the report isn't in the same form that the button. So
    include in the uses clause the unit wherethe report is. If it's a datamodule
    then write something like:

    MyDataModule.Label1.Caption := 'you caption';
    If it's a form:
    MyForm.Label1.Caption := 'you caption';

    Look that you don't write MyReport.Label1.Caption but simply Label1.Caption
    preceeded by the form or datamodule name.
    good luck , bye

This discussion has been closed.