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

Creating bands in code

edited February 2004 in General
The ppReport has only a DetailBand and I want to create header and
footer in runtime.

I'm getting an Access Violation on the third line, why?

ppReport.DefaultBands := [btHeader, btDetail, btFooter];
ppReport.CreateDefaultBands;

ppReport.HeaderBand.PrintHeight := phDynamic;

Thanks!

--
Erick Sasse

Comments

  • edited February 2004
    Hi Erick,

    Once you have created and edited a report with existing bands, you cannot
    use the CreateDefaultBands to simply add new bands on top of it. You will
    need to create the Header and Footer band objects separately and assign them
    to the current report using the Band.Report property.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited February 2004
    Nico Cizik (Digital Metaphors) wrote:

    Ok Nico, so I did it like this:

    if ppReport.HeaderBand = nil then
    with TppHeaderBand.Create(ppReport) do
    Report := ppReport;

    Is this the best way? Do I have to set Report property even if I create
    using the report as parent?

    --
    Erick Sasse
  • edited February 2004
    Hi Erick,

    This is correct. When you pass ppReport as the Band's owner in your Create
    call, you are not setting the Band's parent. The owner of the band should
    either be the form, datamodule or nil. If you do not set the Band.Report
    property, the band will not show up.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.