How to programmatically add a subreport into main report

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Li Pang

    #1

    How to programmatically add a subreport into main report

    Hi,

    I can add a subreport into the main report at the develop time (visual way),
    and everything works fine. However, I'd like to know how to do the same task
    at the run time, ie, when the main report is loading, the second report is
    adding into it.

    Both reports 'main.rpt', and 'subreport.rpt' are predefined, I only want to
    know how to link them together.

    I will approciate if somebody can help me.
  • Mona

    #2
    Re: How to programmaticall y add a subreport into main report

    Hi Li,

    We need to write the following code to add the controls dynamically :


    START CODE

    Dim myLabel As New DataDynamics.Ac tiveReports.Lab el()

    myLabel.Text = "Test"

    myLabel.Name = "Label1"

    myLabel.Width = rpt.PrintWidth

    myLabel.Top = 0

    myLabel.Left = 0

    myLabel.Height = 1

    myLabel.Style = "text-align: center; font-weight: bold; font-size: 72pt;"

    rpt.Sections("D etail").Control s.Add(myLabel)



    END CODE



    We need to add teh following code in order to add a section dynamically :



    START CODE



    With rpt.Sections
    .Add(SectionTyp e.PageHeader, "PageHeader ")
    .Add(SectionTyp e.Detail, "Detail")
    .Add(SectionTyp e.PageFooter, "PageFooter ")
    End With



    END CODE



    Hope thsi helps.



    Regards,

    Mona [Grapecity]

    "Li Pang" <LiPang@discuss ions.microsoft. com> wrote in message
    news:2EF8364C-90DF-429A-8B00-7F4BF7C7E506@mi crosoft.com...[color=blue]
    > Hi,
    >
    > I can add a subreport into the main report at the develop time (visual[/color]
    way),[color=blue]
    > and everything works fine. However, I'd like to know how to do the same[/color]
    task[color=blue]
    > at the run time, ie, when the main report is loading, the second report is
    > adding into it.
    >
    > Both reports 'main.rpt', and 'subreport.rpt' are predefined, I only want[/color]
    to[color=blue]
    > know how to link them together.
    >
    > I will approciate if somebody can help me.[/color]


    Comment

    • Li Pang

      #3
      Re: How to programmaticall y add a subreport into main report

      Hi Mona,

      Thanks for your response. However, I can't see any codes concerning to link
      two existing reports.

      "Mona" wrote:
      [color=blue]
      > Hi Li,
      >
      > We need to write the following code to add the controls dynamically :
      >
      >
      > START CODE
      >
      > Dim myLabel As New DataDynamics.Ac tiveReports.Lab el()
      >
      > myLabel.Text = "Test"
      >
      > myLabel.Name = "Label1"
      >
      > myLabel.Width = rpt.PrintWidth
      >
      > myLabel.Top = 0
      >
      > myLabel.Left = 0
      >
      > myLabel.Height = 1
      >
      > myLabel.Style = "text-align: center; font-weight: bold; font-size: 72pt;"
      >
      > rpt.Sections("D etail").Control s.Add(myLabel)
      >
      >
      >
      > END CODE
      >
      >
      >
      > We need to add teh following code in order to add a section dynamically :
      >
      >
      >
      > START CODE
      >
      >
      >
      > With rpt.Sections
      > .Add(SectionTyp e.PageHeader, "PageHeader ")
      > .Add(SectionTyp e.Detail, "Detail")
      > .Add(SectionTyp e.PageFooter, "PageFooter ")
      > End With
      >
      >
      >
      > END CODE
      >
      >
      >
      > Hope thsi helps.
      >
      >
      >
      > Regards,
      >
      > Mona [Grapecity]
      >
      > "Li Pang" <LiPang@discuss ions.microsoft. com> wrote in message
      > news:2EF8364C-90DF-429A-8B00-7F4BF7C7E506@mi crosoft.com...[color=green]
      > > Hi,
      > >
      > > I can add a subreport into the main report at the develop time (visual[/color]
      > way),[color=green]
      > > and everything works fine. However, I'd like to know how to do the same[/color]
      > task[color=green]
      > > at the run time, ie, when the main report is loading, the second report is
      > > adding into it.
      > >
      > > Both reports 'main.rpt', and 'subreport.rpt' are predefined, I only want[/color]
      > to[color=green]
      > > know how to link them together.
      > >
      > > I will approciate if somebody can help me.[/color]
      >
      >
      >[/color]

      Comment

      Working...