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

Problem with Subreports

edited April 2004 in End User
Hi All,

I am having some problems getting one of my subreports to work correctly and
I was hoping someone could point me in the right direction to a solution.

My main report and subreport use the same data except the main report needs
to be sorted one way and the sub report needs to be sorted in another and
this is where I am having the problem. If I used a completely different
dataview I can get the subreport to display correctly but it loads all the
data which I don't want. I am passing some autosearch values to the main
reports dataview like this:

ppReport1.AutoSearchFields[0].SearchExpression :=
AAAFromCombo.Text+','+AAAToCombo.Text;
ppReport1.AutoSearchFields[1].SearchExpression :=
ServiceFromCombo.Text+','+ServiceToCombo.Text;
ppReport1.AutoSearchFields[2].SearchExpression :=
FundFromCombo.Text+','+FundToCombo.Text;
ldDateExpression :=
DateToStr(PDFromCombo.Date)+','+DateToStr(PDToCombo.Date);
ppReport1.AutoSearchFields[3].SearchExpression := ldDateExpression;
ppReport1.ShowAutoSearchDialog := False;
ppReport1.Print;

The subreport dataview would need to be filtered by the same values as the
AutoSearchFields 1,2 & 3 but use the current main report detail record for
the value of AutoSearchField 0.

How can I accomplish this?

Thanks!

Comments

  • edited April 2004

    Here is an example of applying autosearch values to additional SQL search
    criteria values....

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

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


    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited April 2004
    Thanks for the example but I am not sure if it will work. I am loading my
    reports as templates from a database and if I try to access ppReport1 or
    ppSubReport1 they would be undeclared.

    Phil

  • edited April 2004
    I believe I found a why to get things working with the example you sent.
    Thank you again. I do have one last question.
    One of the search values I would like to pass to the subreport is a value
    from the current record of the main report. How can I do this?

    Currently I have a procedure that looks something like:

    If GetSQLObject(ppSubReport1.Report, lSubReportSQL) Then
    Begin
    lSubReportSQL.Criteria[0].Value :=
    ppReport1.AutosearchFields[1].SearchExpression;
    lSubReportSQL.Criteria[1].Value :=
    ppReport1.AutoSearchFields[2].SearchExpression;
    lSubReportSQL.Criteria[2].Value :=
    ppReport1.AutoSearchFields[3].SearchExpression;
    lSubReportSQL.Criteria[3].Value := <<<How to pass a value from the
    current record of the main report here?
    End;

    Thanks.



  • edited April 2004

    Use the Data workspace to link the detail to the master on the linking
    field.

    You cannot filter the detail while the report is executing. DADE uses RB's
    DataPipeline linking which works by firing the detail query only a single
    time.ReportBuilder's DataPipeline architecture includes support for linked
    data traversal. Whenver the record position of the master data changes, the
    traversal logic compares the master and detail field link values and then
    determines where to locate the record position for the related detail data.


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


    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited April 2004
    I have tried that but I keep getting the same values in the subreport
    regardless if which record the main report is on. Could the fact that I
    have the subreport printing in a group footer have anything to do with the
    values always being the same?


    Thanks.


This discussion has been closed.