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

Dynamic create a TppField and TppDBText but show nothing

edited February 2005 in RAP
Hi,

I try to create a TppField and TppDBText in RAP and hope the result will
shown on report, but it doesn' show out:

procedure GlobalOnCreate;
var D: TppDBText;
F: TppField;
begin
ShowMessage('Do it');
F := TppField.Create(Main);
F.FieldName := 'Company';
F.DataType := dtString;
F.FieldLength := 100;
F.DataPipeline := Main;
Main.AddField(F);

D := TppDBText.Create(Report);
D.DataPipeline := Main;
D.DataField := 'Company';
D.Band := Detail;
D.Left := 3.0;
D.Width := 1.5;
D.Color := clYellow;
end;

The 'Main' is the TppDBPipeline and the AddField method was defined via
RTTI.

Thank you very much.

Best Regards,
C. Yang

Comments

  • edited February 2005

    Try the same code from Delphi first, its easier to trace in the debugger
    that way. And as a first step, execute the code prior to calling
    report.Print

    1. RB 9 introduces some new events to allow preparing data from RAP. The
    Report.OnInitializeParameters and BeforeOpenDataPipelines events.

    I think the GlobalOnCreate event occurs too late.

    2. In your example is there a TDataSet field that corresponds to the
    F.FieldName? Try tracing the source code for TppDBPipeline.GetFieldValue

    3. Remove the Main.AddField() line. Setting the Field.DataPipeline is
    sufficient.



    --
    Nard Moseley
    Digital Metaphors Corporation
    www.digital-metaphors.com



    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
This discussion has been closed.