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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subreport problem

Status
Not open for further replies.

nikol

Programmer
Apr 12, 2005
126
US
I'm working on a report which has "City"parameter as static prompt. In SELECT EXPERT I have the formula
if {?my Parameter} = 'All Cities'
then
1=1
else
{command.city} = {?my Parameter} .
When I refresh the report It asks me for the city. If I do "All cities" , it gives me all clients in all cities otherwise the selected city clients. Its working fine.
But if I insert this report as a subreport in detail section the report splits in many sections. If i have 10 clients the report spilits in 6-7 sections.
Anybody knows why? Where is the problem?
 
Why are you placing it in the details section?

You haven't described what you want, ratehr that you do something and something unexpected occurs.

Subreports in the Details are generally a bad idea, at any rate, the subreport will execute for every row in the details, which means every record.

Rather than stating what you don't want, try posting what you do, including other technical information.

Crystal version
Database/connectivity
Example data
Expected output

-k
 
I'm using CR XI with ODBC connection on third party DB.
I have a report whih is grouped on GENDER like

Female 3
Male 3
Unknown 1
Total Intake 7.
I have used a parameter field"City" & in select expert I have used the formula.
if {?my Parameter} = 'All Cities'
then
1=1
else
{command.city} = {?my Parameter}..
Now,When I uses this report as subreport in report footer & refreshes it, it works fine & gives me correct intakes for all different cities but when I select "all cities", report gives me the last selected city not the count of "all cities" ie intake=7. I hope this will help u in solving my problem.
 
It sounds like your subreport is linked to a field in the main report, and shouldn't be, hard to say since we've no idea what is in the main report, or the data involved, and you don't want to post that information.

-k
 
Subreport is linked to main report by city column. I have used
select uid,city from hservices a
where date_added =(select max(date_added) from
hservices b
where a.uid=b.uid
and question_id=509)
in the main report & a parameter field "city"
& used if {?my Parameter} = 'All Cities'
then
1=1
else
{command.city} = {?my Parameter} formala in record selection of main report. What other information u want please let me know.
 
So if the report is in the report footer, it will demonstrate the last row of the main report because the report footer fires at the end of the report, which is the last record in the main report.

Modify the subreport record selection formula to something akin to:

(
if -->{?my Parameter} <> 'All Cities' then
{subreport.field} = --> {maintable.field}
else
else if -->{?my Parameter} = 'All Cities' then
true
)

You can get both the parameter and the field available in the subreport by linking by both, then by modifying the record selection you can alter what it's doing.

Note that the way you've contructed your record selection you may not be passing the SQL to the database, hence my method.

-k
 
I tried to change the record selection formula of subreport as (
(
if {?pm-command.city} <> 'All Cities' then
{command_3.city} = {command.city}
else
else if -->{?pm-command.city} = 'All Cities' then
true
)

Its giving error on {command.city} that
" Field name is not known
 
I think you should create the same parameter {?city} in both main and subreport and then in the subreport record selection area, use:

(
if {?city} <> 'All Cities' then
{command_3.city} = {?city} else //assuming command_3 is sub table
if {?city} = 'All Cities' then
true
)

Then in the main report go to edit-subreport links-> and link {?city} in the main report to {?city} in the subreport, using the dropdown to select {?city}, NOT {?pm-?city}.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top