BiGXERO
BiGXERO

Reputation: 7244

Change Group Name in Crystal Reports to non-Database Value using Formula

I am looking to change the group names in a crystal report to a specified text value not located within the database.

e.g. i have a 'status' field that can either be 'i' or 'a'. I would like these to display as 'inactive' or 'active' in the group headings. The code i currently have in the 'Use a formula as group name' is:

stringvar newGroupName;
if (groupname = "I") THEN newGroupName:= "Inactive" ELSE
if (groupname = "A") THEN newGroupName:= "Active" ELSE
newGroupName:= groupName;
newGroupName

However this says i am passing too few arguments for the groupName reserved word.

Have looked on the net but have not found anything for defining non database names using the groupname function. Any help greatly appreciated.

Upvotes: 1

Views: 6495

Answers (2)

bendataclear
bendataclear

Reputation: 3850

Just to add, I always add a standard formula to the formula list to calculate the group names :

if {table.field} = 'I' then
    'inactive'
Else if {table.field} = 'a' then
    'active'
Else
    'unknown'

Then in the group name formula in the group expert I refer to the formula like {MyGroupName}

This makes it much easier and quicker to edit the names but also will not be lost if you edit the group field (very useful if you have a large amount of code).

Upvotes: 2

Lee Tickett
Lee Tickett

Reputation: 6027

Make sure you pick fields from the window they will appear like {table.field} etc

There is no need for variable here just do something like:

if {table.field} = 'I' then
 'inactive'
Else if {table.field} = 'a' then
 'active'
Else
 'unknown';

Upvotes: 1

Related Questions