Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sorting subreport by parameter in main report

Status
Not open for further replies.

newjim

Programmer
Sep 8, 2001
21
CA
I would like to have a parameter in my main report where the user can specify the sort order for a subreport, for example, "category" or "startdate".

I've made a formula to create a shared variable from this main report parameter:
Shared StringVar subReportOrder;
subReportOrder := {?History Order}

I've also made a formula in my subreport:

Shared StringVar subReportOrder;
if subReportOrder = 'Category' then
"HISTORY.CATEGORY"
else
"HISTORY.STARTDATE"

Finally, I clicked the sub report Sort Order icon and tried to select my subreport formula. However, it doesn't appear in the list.

Suggestions?
 
Instead of using a shared variable, I would create the same parameter in the subreport, and change the formula to:

if {?History Order} = 'Category' then
{HISTORY.CATEGORY}
else
{HISTORY.STARTDATE} //Note that I replaced your text with fields

Use this to group on or in the record sort area. Then in the main report go to edit->subreport links and link the {?History Order} parameters to each other. Be sure to use the dropdown for the subreport selection in order to choose {?History Order}, and NOT {?pm-?History Order}.

-LB
 
Thanks, that worked perfectly.

The only tricky part is seeing that when you click {?History Order} as "Field(s) to link to", you click the down arrow of the "Sub report parameter field to use" listbox and there is a tiny scrollbar that allows you to select either "{?pm-?History Order}" or "{?History Order}". That tiny scrollbar is hard to see.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top