Home Subreports

subreport not printing when empty data

edited December 2003 in Subreports
I have a subreport connect to a query through pipeline, the problem is if
the query return no record, then the subreport will not be printed. But I
have some other information want to display in the subreport, so
How to make the subreport still visible if the underlying query has no
record?

Comments

  • edited December 2003

    Reports and ChildReports have a NoDataBehaviors property that can be used to
    control what happens when there is not data. See the RBuilder.hlp for
    details.

    Select the tab displayed at the bottom of the report designer to access the
    workspace for the childreport. The ChildReport becomes selected in the
    object inspector. Use the object inspector to set the NoDataBehaviors
    property.


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

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited January 2004
    Hi all,

    I have the same kind of problem.
    When I put a
    ShowMessage('No data');
    in the OnNoData event of this subreport, I see the dialog box with this
    message.
    The subreport contains only a variable wich content is calculated
    (concatenation of 2 fields of a query).
    When the query is empty, I would like to see this : '-' (minus character).
    When I add the code :
    MyVariable.Text := '-';
    ShowMessage('No data');
    in the OnNoData event of this subreport, I see the dialog box but the
    variable is not printed.

    Any idea ?

    Thanks,

    Patrice.




  • edited January 2004

    Try setting the NoDataBehaviors to ndBlankReport and use a Label rather than
    a Variable. Use the Label OnPrint event to assign the Label.Caption.


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

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited January 2004
    Hi Nard,

    This does not work either.
    This is the code snippet for the OnPrint event of the label :

    procedure TDM_DocTrav.lblNomPrenomPrint(Sender: TObject);
    begin
    lblNomPrenom.Caption := qEnseignants.FieldValues['C_NOM'] + ' ' +
    qEnseignants.FieldValues['C_PRENOM_1'];
    if qEnseignants.RecordCount = 0 then
    begin
    lblNomPrenom.Caption := '-';
    end;
    end;

    The minus character is never shown since this event is not triggered when
    the dataset named "qEnseignants" is empty.

    Patrice.

  • edited January 2004

    Make sure that for the ChildReport you have NoDataBehavior set to
    ndBlankReport.

    When I try it here using RB 7.03 it works.

    Try downloading a trial version of RB 7.03 and perform the same test.

    Create a simple example using DBDemos data and e-mail in zip format to
    support@digital-metaphors.com and we can check it out here.


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

    Best regards,

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