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

Pass parameter from main report to subreport 1

Status
Not open for further replies.

elansienna

Technical User
Jun 18, 2004
44
US
First, let me say that I've found this forum to be a great resource in developing reports! I have not found any of the threads that mimic the problem I have currently having, so I am addressing the forum. I am using Crystal v10 with an ODBC connection to Oracle 9i. I have a main report with several subreports that is parameter driven. The string value is fed from the main report into the subreport. The links are correct and I get back the necessary data. However, I needed to bring a null record into the subreport and found the need to use the add command with a union to dual to create a null record as the parameter would not allow nulls to pass. I created a parameter on the add command, used it in the command and it works only when I enter the value manually from the subreport (single quote value). However, when I try to pass a value from the main report to the subreport, I get an error "incorrect identifier" and double quotes on the string value that I am trying to pass. It looks as if Crystal is trying to pass the value with double quotes. Help!
 
If you simply need a record full of nulls into a subreport, just fake it by creating variables.

Not sure why this would prove helpful, perhaps if you share some sample dtaa and expected output you'll find another idea that makes more sense overall?

As you probably know, subreports are eeeeeeee-vuuuuuhl, though sometimes a necessary one..

-k
 
Thank you synapsevampire for your rapid response! I guess what I need to do is be more explicit in what I am trying to achieve. Essentially, my goal is to have a conditional message ("NO RECORDS FOR THIS CUSTOMER") that prints if the subreport comes back blank instead of a blank page. The reason for the null is to test for "no records". I'm using an isnull logic on the recordset brought back by Dual if no records appear in the table for a customer. This way I'll have a null to test.

SELECT
ba.BDWH_ORG_NAME,
ed.SDA_DATA_DEVICE_NAME,
ed.SDA_EVENT_COUNT,
ed.SDA_DATA_EVENT_DAY,
ed.SDA_DATA_SERVICE_ID
FROM
BASEWH.BDWH_ORGANIZATION_DIM_MV ba,
EVENT.SDA_FW_UDP_DTOP_10_V ed
WHERE (ba.BDWH_ORGANIZATION_ID = ed.ORGANIZATION_ID )
and ba.BDWH_ORG_NAME = {?ORG_NAME}
AND
ed.sda_data_event_day = trunc(sysdate) - 1
UNION ALL
select NULL,
Null,
0,
trunc(sysdate) - 1,
NULL
from DUAL

Unfortunately, the parameter does not allow the null to pass into the report. Any suggestions to make life easier? Thanks
 
You don't need this.

Create a shared variable to test, and check the value in the main report if no records are returned:

Main report formula before the subreport fires:
whileprintingrecords;
shared booleanvar GotRows := false

Subreport formula in details;
whileprintingrecords;
shared booleanvar GotRows;
If recordnumber > 0 then
GotRows:=True

Main report formula Afetr the subreport fires:
whileprintingrecords;
shared booleanvar GotRows;
If GotRows then
"I had data"
else
"Nope..."

I would suggest that you provide technical information and request design assistance rather than stating how others must do something until you become more familiar with the tools, your way was the looooong ways home...

You could also have used a SQL Expression to accomplish this.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top