Finding all uses of a variable

Wednesday 10 March 2010 @ 5:01 pm

Starting with v11.5 Crystal has made it easy to find all uses of a field within the formulas of a report.  Just right click on the field  (database, formula, parameter, etc) and select “Find in formulas”.   Even for those of you using older versions of Crystal there is a workaround in my Expert Techniques vol. 1.

But finding where a variable is used is a bit trickier.  Unlike fields, there is (currently) no central list of all the variables used in a report.  But I just noticed a feature that must have been in the formula editor for at least 2 years.  Open a formula and click on the binoculars on the tool bar.  This allows you to search a formula for text and even do global replaces within the current formula.  Now there is an option in the list that says “All Formulas”.  This will allow you to search all formulas for the existence of any string.  It will list all of the occurrences in the bottom of the window allowing you to click on each occurrence to open that formula in edit mode.

There are two limitations.  It doesn’t include formulas in the subreports.  These have to be checked individually.  It also doesn’t allow you to do a global replace in one stroke across formulas like it does within a single formula.  A global replace has to be done in each formula.  But even with those limitations it is much better than the old method of exporting to “Report Definition” and searching through the text file.

One last note.  If you do need to do a global replace through all the formulas in a report or even across reports, you might want to look into .rpt Inspector.   This is the only tool I know of that lets you open, change and save formulas in multiple reports at the same time.  You can find out more about it in the  my LINKS page in the section marked “Mass Edit & Analyze”

(For examples of my most popular formulas, please visit the FORMULAS page on my website.)







Leave a Reply

Jeff-Net
Recrystallize Pro

Crystal Reports Server