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!

Display a field value based on the input parameter 1

Status
Not open for further replies.

SuperTime

Programmer
Dec 21, 2004
183
US
Hi,

I want to display the {product.desc} field based on the product ids that were selected in the parameter.

{?product_id}
this parameter allows selection of multiple product id's

However on the report I have to display the relevant {product_desc} field values.

I am using crystal 9.0

Please advice.
Thanks.
 
In the report->selection formulas->record place:

(
{table.productid} = {?product_id}
)

This will limit the rows returned, so just place your description field in the details.

If you mean that the description field has the ids in it, then adjust the formula to:

(
{?product_id} in {table.desc})
)

-k
 

I have to display the prod_desc in the report header.

Also prod_desc is a seperate field

So the same table contains both the prod_id as well as prod_desc.

But in the report header instead of displaying the prod_ids that are selected inthe parameter list I want to display the relevant prod_desc's
 
Too vague for me, please post technical information:

Crystal version
Database/connectivity used
Example data
Expected output

Only the first Row displays in the report header, so either you don't understand Crystal, or I don't understand you.

Why do you care if it's in the report header anyway? You can make other sections show up in the beginning of a report.

-k
 
If you don't have too many IDs, you can handle this by a formula, as in:

numbervar i;
numbervar j := ubound({?product id});
stringvar display;

for i := 1 to j do(
display := display +
(
if {?product} = "1234" then "Cereal" else
if {?product} = "3456" then "Vegetable" else
if {?product} = "5678" then "Meat" else "Other
) + ", ");
left(display,len(display)-2);

If there are many options, then insert a subreport that displays the description field in the detail section and then link the subreport to the main report by selecting {?Product_ID} as the main report linking field and selecting {table.product_ID} in the subreport as the field to link to. Suppress all but the detail field, and place the subreport in the report header.

-LB
 
I did something simialr.
I created a subreport products.And within that subreport I have a group for prod_desc, this displays the right data.
However is it possible to display the data horizontally comma seperated?

Now:
Cipro
Avelox
Nasonex

Required:
Cipro, Avelox, Nasonex


Other info: using crystal 9.0
 
Place the description field in the subreport details section, and then create two formulas:

//{@accum} to be placed in the detail section:
whileprintingrecords;
stringvar desc := desc + {table.description} + ", ";

//{@display} to be placed in the subreport footer:
whileprintingrecords;
stringvar desc;
left(desc,len(desc)-2);

-LB
 
Due to report requirements and integration of this report in ASP.net I cannot link the parameter on the main report to the subreport. However I can link any other field present on the main report to the subreport.

Is there any way to still show tha list of product desc for the products selected on the subreport without linking the prod_id parameter field?

I will describe the whole thing again, I am using Crystal 9.

I have a main report that has parameter ?-products. I am accepting a list of product_ids from the submission table.

I have a subreport which has to display the relevant product description from the same submission table in the subreport. The subreport has to be placed in the page header section of the main report.

The display of the prod_desc on the subreport has to be of the format ProdA, ProdB, ProdC....

Please advice.

Thanks.
 
I don't know anything about integration with ASP.net, but it surprises me that you cannot use a parameter for linking to a subreport. If you can't do this, then I think you have to use my first suggestion to display the descriptions.

-LB
 
Without rereading the entire thread, try just Linking the field in the main report to the field in the subreport, you don't need to use the parameter.

-k
 
Yes what is happening is that when the report with the subreport linked by the parameter is integrated in the ASP.Net environment that subreport shows up but without any data.

When we try to integrate subreport that is not linked by the parameter field it work abs. fine.

we are not able to locate where the issue is. hence to make it work I am trying to see if there is another solution to my problem where I can use the subreport without the parameter being linked.

But unfortunately I wont be able to use the if loop cause there are more than 100 products in the db.

 

According to synapsevampire's suggestion I tried to link the prod_id field on the main report to the same field on the subreport. That does not work, because my subreport then just diplays the product desc for the last prod_id that was selected on the main report. However I want to get the array of all prod_ids selected in the parameter in the main report and pass it to the subreport to show all the description.
 
You could try to pass a shared variable. First, in the main report create this formula and place it in the report header section:

whileprintingrecords;
numbervar i;
numbervar j := ubound({?ProdID});
shared stringvar IDs;

for i := 1 to j do(
IDs := IDs + {?ProdID}+", ");
left(IDs,len(IDs)-2);

Then in the subreport add the following formula to the detail section:

whileprintingrecords;
shared stringvar IDs;
stringvar accum;

if {table.prodID} in IDs and
instr(accum,{table.proddesc}) = 0 then
accum := accum + {table.proddesc} + ", ";

Suppress all subreport sections except the subreport footer where you will place this formula:

whileprintingrecords;
stringvar accum;
left(accum,len(accum)-2)

This tested out for me, but I'm not sure whether this will solve the issue using ASP.net.

-LB
 
I tried as you suggested, but only one product desc is being displayed on the subreport, does not show all of them

Main Report
RH: @test
whileprintingrecords;
numbervar i;
numbervar j := ubound({?products});
shared stringvar IDs;

for i := 1 to j do(
IDs := IDs + {?products}+", ");
left(IDs,len(IDs)-2);

Sub Report
D: @accum
whileprintingrecords;
shared stringvar IDs;
stringvar accum;

if {RDS_SUBMITEM.SUBMITEM_PROD_ID} in IDs and
instr(accum,{RDS_SUBMITEM.PROD_DESC}) = 0 then
accum := accum + {RDS_SUBMITEM.PROD_DESC} + ", ";

F: @showproducts
whileprintingrecords;
stringvar accum;
left(accum,len(accum)-2)


Subreport Linked on: {RDS_SUBMITEM.SUBMITEM_PROD_ID}


When I run the report and select just one product that displays on the subreport. But when I select two or more product ids only the last product desc shows in the subreport.

Is there anything I am doing wrong?

Please advise.

Thanks.
 
My solution is for an UNLINKED subreport. You cannot link on the product ID and still get all IDs displayed in the page header. All you need to do is remove the link, and it should work.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top