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!

CR6: Assign variables once and use in many formulas

Status
Not open for further replies.

jiggs

Programmer
Feb 22, 2001
3
US
My report has multiple formulas which perform actions depending upon the value of certain text strings (that contain dates in format: 20010331). My problem: I have to edit each formula each month to change the date ranges. With multiple reports and about a dozen formulas to change, it gets pretty time-consuming.

Is there a way to set the beginning and ending date ranges once (say, as a variable), and then be able to reference those variables in formulas? Also, if the above is possible, how then would I reference the variable name in a formula (such as Mid( ))?

Thanks.
 
Are you launching the reports from an application? Give version info. Ken Hamady
Crystal Reports Training/Consulting and a
Quick Reference Guide to VB/Crystal (including ADO)
 
CR version 6. No, not being launched by an application. Data resides in MS-Access tables.

Basically, can I assign a value to a variable and reference that variable in functions (like Mid()) later in the report? This would allow me to set the beginning and ending date ranges (eg: 20010301 and 20010331) only once and use these values throughout the report.
 
It would be simpler to create two formula fields that contain the literal values (they look like character string values) such as:

the formula called {@startdate} could store:
"20011231"

You could then use this field in your mid function in as many formulas as you like. This would be simpler than using a variable and much simpler than changing all of your formulas, but you would still have to change the formula in every report.

Can the dates be derived automatically from the system date when the report is run?
Or possibly from a parameter prompt?
Or, can you store these values in a table that can be referenced in each report so that you can change the values once for every report? Ken Hamady
Crystal Reports Training/Consulting and a
Quick Reference Guide to VB/Crystal (including ADO)
 
Ken,
Thanks very much for the suggestion. I implemented your suggestion and it works great! *:->*
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top