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

subreport when detail section is blank

Status
Not open for further replies.

mmarino

Programmer
Mar 22, 2002
42
0
0
US
Hi there, I have a report with a few subreports, they're all linked by customer id (the main report is on only one customer id).
Ocasionally, the details section of my main report will be empty, but I still want the subreports to show (it has different information about the customer).
What happens now is that as long as there is at least one detail line, everything works ok, but when there are no details, then the subreports don't show up either.
I don't know if there's a way to do this. Can someone point me in the right direction?
Thanks in advance :)
 
A quick and dirty fix is to make sure that the report always returns a row.

A main report is intended as a container, if it isn't going to return rows then iut isn't suitable as a container.

Also you may be able to get around this depending upon your version of Crystal...

-k
 
The Report Header or Footer will always print.
Try placing your subreports there instead of the Details or Group Header/Footer sections.


Bob Suruncle
 
Thanks for the reply Bob. I tried that, but I still don't get anything in the subreport. Basically, my main report comes from 3 tables, one of them is the Customer table. The subreport comes from only one table (CustInfo table). Those two tables are linked on Customer Id, but I'm passing this parameter from the main report to the subreport. The detail section will sometimes be blank, because we have no entries for a particular customer, but they may still have an entry in the CustInfo table, so I want to show this on the subreport.
btw, I'm using Crystal XI and SQL 2000
Thanks!
 
I don't have XI in front of me right now, but I do have v10.
I created a test report from the Customer table of the Xtreme sample database.
I created a numeric parameter for Customer ID, and set my record selection to be
{Customer.CustomerID}={?CustID}
AND {Customer.CustomerName}="XYZ"
(this ensures that the main report will return 0 records)
I created a subreport, also from the Customer table, and also with a numeric parameter for Customer ID called {?SubCustID}.
I inserted the subreport into the report header of the main report, and linked the subreport using the {?CustID} parameter of the main report to the {?SubCustID} parameter of the subreport.
Even thought the main report returns 0 records, the subreport returns records for the customer ID that I select.

Does your scenario match this, or are you using the actual Customer ID field from the main report to link to the subreport?
Or, are there other fields that help create the link to the subreport?


Bob Suruncle
 
I am using the customerid from the main report to link to the subreport. Basically I'm doing that because the parameter passed to the main report is a customer number, different than the id (that's how the database is defined). So what I'm doing is getting the custid based on the custnumber given, and then passing this to the subreport. Now that you mention it, I can see why it wouldn't turn any records... not an obvious one though...
I guess what I can do is change the main report to somehow pass the cust id to the details and the subreports without being dependent on having records returned... I also thought about making the details section a separate subreport... any ideas or comments?
Thanks for the insight though, I don't think I would've thought of that :)
 
CustomerID from which table? If you don't have a customer ID in the main report to link to the subreport on, then the subreport won't run. If you have CustomerID in more than one table in the main report, use the field from the table where you ALWAYS expect there to be data (referred to as "master" table below).

Also, you might want to check the table links in your main report - you'll need to use a left outer join from the master table to any child tables with CustomerID. That way you'll always have the customer data even if there's no data in the child tables.

-Dell

A computer only does what you actually told it to do - not what you thought you told it to do.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top