If you create reports for others, you might find a use for this technique. It changes a report automatically based on the folder where the report is stored. I use it to show a message in preview while in my design environment and have the message automatically suppress when the report is moved to production.
Example:
I have a handful of customers that still use v8.5 which is almost 15 years old. Unlike all versions of CR from v9 forward, there is no way to save changes done in a later version of CR back into v8.5. So I have to maintain a copy of v8.5 just to use for these customers. When I receive a report to change the version doesn’t usually matter, so I don’t always remember to check and see if the customer still uses v8.5. I might do quite a bit of work on the report in my current version before I check. Only when I go to save the file does CR warns me that the report is from the older version of CR (if I do “Save As” it won’t warn me at all). At that point I have to reopen the original report in v8.5 and make all the same changes a second time.
So I just came up with a way to add a warning to reports that I work on in v8.5. This warning will appear in my preview window as soon as I open the report in my environment, but will never appear to the customer. It works because I use each customer’s account number as a folder name to store all of their reports. This helps because Crystal formulas can read the path and file name of the report being run. So when I work on a v8.5 report I add logic to have it check for a specific folder to control the appearance of the warning.
I create a new Report Header section that isn’t otherwise used by the report.
I place a text object in this new section that has a large bold red warning “>>> use v8.5 <<<”
I create a section suppression formula that says something like:
not "\1234\" in FileName
The 4-digit number is a customer account number which is where the rpt is stored in my environment. It is unlikely that the report will be in a folder with that same name in the customer’s environment. So the section will suppress in their environment but show up automatically in mine the next time the report is opened.
I found on surprise while testing this. The FileName function is read before the selection formula is processed, so you can use the folder name to change your filter. And it is even processed early enough to affect the SQL that CR automatically generates, so it doesn’t have to slow down the report. If you discover any creative uses for this, please share.
(For examples of my most popular formulas, please visit the FORMULAS page on my website.)