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

problem with shared variable - date

Status
Not open for further replies.

BJD

Technical User
Jun 22, 2001
27
US
In my subreport I have a field called Desired_ship_date that I want to pass to my main report. Not every record in the main report will have records in the subreport so Desired_ship_date from the subreport will be null on some records. When I try my shared date variable, it works on the first record which does have information in the subreport. My second report in the main report does NOT have information in the subreport and the shared variable shows the value from the first record. How do I use my shared date variable only when it is NOT null? I do have the shared variable in a section below the section containing the subreport. More information on my formulas below:

in the subreport
WhilePrintingRecords;
Shared dateVar DS_DES_SHIP_DATE:= {DESIRED_SHIP_DATE}

in the main report
WhilePrintingRecords;
Shared dateVar DS_DES_SHIP_DATE;
DS_DES_SHIP_DATE
 
Maybe you could get the number of records returned by the sub report. If it's zero, then hide the Desired_Ship_Date on the main report, else, display it.
 
You could also reset the shared variable with another formula:
Shared dateVar DS_DES_SHIP_DATE:= Date(0,0,0)

Place this formula in the main report in same section as the subreport. It will be processed before the subreport and will set the date to 0 as needed
Editor and Publisher of Crystal Clear
 
I have had this come up in other data formats as well

What I do is in an initialize formula for the subreport placed in the report header I set the Shared variable to some non-null value (eg. zero or a ridiculous number like 9999999 if it is a numeric value or ' ' for strings if that is ok.

This always seems to be executed...even though the report itself does not return any values. so I get a returned value from my subreport no-matter-what.

so you might try this with an unreasonable date such as Jan 1, 1980....

Jim
 
I added a new formula in my subreport of
WhilePrintingRecords;
Shared datevar DS_DES_SHIP_DATE:=Date (1929,01 ,01 )

and in my main report of
WhilePrintingRecords;
Shared DateVar DS_DES_SHIP_DATE;
DS_DES_SHIP_DATE

and now my original shared date variable always returns 1/1/29 even if there is a record in the subreport. I have the new formula in the report header. What am I missing?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top