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!

Q: How can I create a constant to use in my report?

Status
Not open for further replies.

carynbo

MIS
Feb 11, 2003
57
US
Hi all. I need to run a report based on Year, whose value changes one time annually. I do not want to prompt for a year or use the system date, but rather, have a CURRENTYEAR field that I can set and use in formulas, selecting records, and display in report headers. I could then display trends testing for (CURRENTYEAR-1), (CURRENTYEAR-2), etc.

For instance, I want CURRENTYEAR = 2002 now, and at some point I will update CURRENTYEAR to = 2003.

I am trying to figure out how to create this constant as a custom function to put in the Repository Custom Functions, without success.

Any suggestions would be greatly appreciated!

Caryn
 
Personally, I'd use a number parameter, and set its default value to whatever is my "Current Year".

However, if you'd like, you could just create a formula in the Report Header that sets a Global Numbervar.

eg
BeforeReadingRecords ;
Global Numbervar CurrYear := 2002

Note that the word Global is optional, if the scope to a variable is omitted, it is assumed to be Global.




HTH
Bob Suruncle
 
Hi Bob,

Thank you very much for your two solutions. Your response made me realize I left out two issues from my question:

IF POSSIBLE, I want a constant that I can set centrally and:

(1) refer to in multiple reports, and

(2) use in SQL Expressions. For instance, I display headcount trends in columns across the page. The following SQL Expression gives the HEADCOUNT for salespeople in 1998. I would like to substitute a constant (custom function in the repository?) for '1998' in the following:

decode ("TABLE1"."SALES_YEAR", '1998',1,0) * "TABLE1"."HEADCOUNT"

To my knowledge, I don't believe I can use the RH formula or a parameter in an SQL expression (also, I do not want to be prompted for the parameter each time the report is run).

Thank you for your time,

Caryn


 
Caryn,

One option is to create a single record table in the database and maintain all the constants you need there.

Cheers,
- Ido

CUT, Visual CUT, and DataLink Viewer:
view, e-mail, export, burst, distribute, and schedule Crystal Reports.
 
Thank you Ido. I think we will do that -- we were just hoping to be able to create a constant in Crystal.

Thanks again!

Caryn
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top