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

accessing subreport labels from another subreport

edited June 2003 in RAP
Hello,

I have a subreport1 which contains some subreports and text, there is a
specific label say label1 in subreport1 that I want to make invisble from a
subreport of subreport1. I can't find the correct syntax and am beginning to
wonder if this is possible ??

eg. I have an employee table the subreport1 and I have a label1 says "none"
and the other subreport2 it is a table of empoyee's that have a company car
which is is another pipeline, so if the employee has a car I want to set the
label.visible to false.

I hope this is clear, but basically when I try and access the label from the
second subreport it gives a compilation error. I have tried putting in the
context but I still have an error.

thanks if you can help

Alex

Comments

  • edited June 2003
    The scope of RAP code is applicable only inside the subreport. You can't
    reference object outside of the subreport. This was done so the end user can
    code simple calculations without having to see naming conflicts. For
    example, ppLabel1 can exist in Subreport1 and Subreport2. You know this
    can't be when they are both owned by the same Delphi form, so what we do is
    allow the Name to be ppLabel1 and ppLabel2, but to the end user, they only
    see the UserName property which is set to ppLabel1 and ppLabel1. This way
    they don't know that there is sucha thing as naming conflicts.

    To do more advanced calculations where you go outside of the scope of a
    subreport, you'll have to use a RAP global Variable. Since you can see all
    the variables in the global OnCreate event, you han declare a global
    variable of type TppLabel that points to ppLabel1 in either subreport. This
    way in your subreport RAP code, you can reference the other subreport's
    label via the global variable which points to it. Here is an example of
    using this technique for other calculations, but you'll get the idea

    http://www.digital-metaphors.com/tips/MDRapRunningTotal.zip:


    Cheers,

    Jim Bennett
    Digital Metaphors


This discussion has been closed.