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

Access data value for dbText component at Runtime via RAP

edited March 2004 in End User
I am trying to get teh value of a dbtext component at runtime via an end
user reporting application using RAP on the Calc Tab.

I have coded the OnDrawCommandClick and OnDrawCommandCreate Events for the
DBText in hopes that I could capture the field value and store it in the Tag
property to allow to a custom RAP function to spawn a New report based on
this value. At this poingt I am just trying to get a showmessage popup to
display the value of the current dbText's underlying data.

FYI using RB Enterprise 7.03

Here is the code I am using on the Calc tab

procedure SurveyIDOnDrawCommandCreate(aDrawCommand:TObject);
begin
SurveyID.Tag := Im_Surveys['Surveyreq Id'];
end;

procedure SurveyIDOnDrawCommandClick(aDrawCommand:TObject);
begin
Showmessage(IntToStr(SurveyID.Tag )):
end;

When I run the report I get a popup with the value 30878 which is the last
surveyID in the report.

I realize I am missing something, is there a better way to accomplish what I
am trying to do via the end user Calc (RAP) interface.


Thanks

Phil Grant

Comments

  • edited March 2004

    Each time a report element such as a TppDBText renders itself onto a page,
    it generates an associated TppDrawCommand object - or more precisely a
    descendant of TppDrawCommand. The TppDBText class generates TppDrawText
    components.

    The OnDrawCommandCreate and OnDrawCommandClick are fired when the
    DrawCommand is created and when it is clicked. The DrawCommand object is
    passed as a parameter to the event-handler method. You need to typecast this
    object as TppDrawCommand or TppDrawText and then


    procedure SurveyIDOnDrawCommandCreate(aDrawCommand:TObject);
    begin
    TppDrawcommand(aDrawCommand).Tag := Im_Surveys['Surveyreq Id'];
    end;

    procedure SurveyIDOnDrawCommandClick(aDrawCommand:TObject);
    begin
    Showmessage(IntToStr(TppDrawcommand(aDrawCommand)..Tag )):
    end;


    and





    --
    Nard Moseley
    Digital Metaphors
    http://www.digital-metaphors.com



    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited March 2004
    I have tried this with no sucess, I get 0 for all rows.

    After this result I placed showmessage(IntToStr(Im_Surveys['Surveyreq
    Id'])); in the SurveyIDOnDrawCommandCreate(aDrawCommand:TObject); method.
    This resulted in a pop up for each record with the correct survey ID, when
    I use your code examples below I get the default tag value. Have I missed a
    step?

    Regards,

    Phil Grant
    IC Solutions, Inc.


  • edited March 2004

    I resarched this and found that in RAP I had to declare a local lDrawCommand
    variable. (Rap has limited ability to type cast. I think when you want to
    assign a property value to an object, it needs a local object reference.)


    example:

    var
    lDrawCommand: TppDrawCommand;
    begin
    lDrawCommand := TppDrawCommand(aDrawCommand);
    lDrawCommand.Tag := plCustomer['CustNo'];
    end;



    --
    Nard Moseley
    Digital Metaphors
    http://www.digital-metaphors.com



    Best regards,

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