Home General

Blank One Page form

edited April 2010 in General
I have a form that is printed, its a tax bill, with data, lines, etc on
it, one record per page. Is there an easy way to have something in the
application that will print a sample form? I.e. either have a button
that will hide all the DBText objects (rap code?), or preferable (maybe)
have something that will print the dbfield names instead of the data as
a one page report.

I hope this makes sense.

Comments

  • edited April 2010
    Hi Jeff,

    One option would be to create a simple report object loop that sets the
    visible property (or text property) of each component you would like to
    change before printing the report. Take a look at the following article on
    how this can be done.

    http://www.digital-metaphors.com/rbWiki/Delphi_Code/Layouts/Report_Object_Loop

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited April 2010
    I tried that, this is basically the code I used:

    procedure ChangeDBTextValues(aReport: TppCustomReport);
    var
    liBand: Integer;
    liObject: Integer;
    lObject: TppComponent;
    begin
    for liBand := 0 to aReport.BandCount-1 do
    begin
    for liObject := 0 to aReport.Bands[liBand].ObjectCount-1 do
    begin
    lObject := aReport.Bands[liBand].Objects[liObject];

    //if the object is a subreport make a recursive call to this routine.
    if (lObject is TppSubreport) then
    ChangeDBTextValues(TppSubreport(lObject).Report);
    if lObject is TppLabel then
    begin
    end
    else if lObject is TppDBText then
    begin
    (lObject as TppDBText).Text := lObject.Name;
    end
    else
    lObject.Text := lObject.Name;
    end;
    end;
    end;

    It does not appear to be setting the dbtext fields. Any idea why

  • edited May 2010
    Hi Jeff,

    The issue here is the timing. I assume you are calling this routine before
    the report or band prints. The problem is that the text is not assigned to
    each DBText until it is generated so all the changes you are making are
    being overwritten.

    One option would be to implement a generic OnGetText event and assign it to
    each DBText you would like to alter. This event would allow you to change
    the value at the correct time.

    Another option would be to use the Report Object Loop to hide all the DBText
    components and show another component in their place (TppLabel) which you
    assign the value to.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

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