Using auto-complete in Crystal Reports formulas

Wednesday 6 March 2013 @ 12:36 am

When you do something one way for a long time, it can be hard to get out of the rut. So even though the Crystal formula editor has a pretty good ‘auto-complete’ feature, I still don’t take full advantage of it. I still tend to scroll through the list of fields. But recently I have started to take advantage of auto-complete to speed things up.

The auto-complete in CR has two components. One is for fields which was introduced in CR v12(2008). The other is for reserved words like functions and was introduced in CR v10.

If you want to enter a field you simply type a curly bracket into the formula editor. A list of fields will pop up. At that point it will include a list of all the field objects that you have created (ie formulas, parameters, running totals, etc) and it will include a list of the data tables used in the report. If you type one or more characters after the bracket the list will get shorter, including only the fields and tables that start with those characters.

Once the list is short enough you can scroll down and highlight the field or table you need. You select the field or table by hitting either enter or tab. If you are on a field when you hit enter then that field will be inserted into the formula. If you are on a table then that table name will be inserted into the formula followed by a period. Another drop down will now appear so that you can repeat the process to select a field. You can type a few characters to shorten the list or select a field by highlighting it and hitting enter or tab.

Reserved Words:
If you want to enter a reserved word like WhilePrintingRecords or DrillDownGroupLevel you can type the first character or two of that word and then click Ctrl-Spacebar. This will pull up a list of all the reserved words that match those starting characters. You can then type characters until you see the word and select with a TAB or ENTER. If there is only one word that matches what you have typed it will be entered automatically.

But there is one small annoyance I have found. It happens when I am deleting part of a formula and accidentally delete the initial bracket of a field name. Typing that bracket automatically invokes the auto-complete which also adds the right bracket, and opens the drop down list of fields. I have to delete the extra bracket and I can’t use the up/down arrows till I leave that field.

Leave a Reply

Recrystallize Pro