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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CR 10 - Crash when filtering on a formula

Status
Not open for further replies.

shera4111

Programmer
Apr 12, 2006
27
CA
Anyone know what I might be doing to crash Crystal?

I have a formula called 'Grouping' that defines three StringVar arrays, then runs an if-elseif-else statement to see if the value in my 'group' field is in any of those arrays. It returns either "Group1", "Group2", "Group3", or "Others".

It seems to work fine if I throw it into the detail section of the report.

If, however, I want to filter on the value that formula returns, Crystal crashes each and every time.

Any thoughts on why, so I can try to come up with a workaround?

Thx.
shera4111
 
Do you mean you are putting the test in Record Selection? That's just for properties of individual records.

Does 'crash' mean that Crystal rejects the code, or does it run and fall over. If so, please post the code, it would be a point of interest.

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
By 'crash', I mean that I get a little popup telling me that 'CR32 has experienced an error and needs to close, we are sorry for the inconvenience'. Then you hit OK and Crystal closes.

As to my filter, yes, I have put it in the select expert. I asked it to filter records using my {@Grouping} formula, where the value was equal to "Group1"

Theoretically, if Crystal would behave, I intend to tie the selection criteria to a parameter, as opposed to the hard-coded "Group1". Which is why I want to use the formula instead of the 'the value is one of the following' condition.

The basic formula looks like this:

StringVar Array Group1 := ["a", "b", "c"];
StringVar Array Group2 := ["d", "e", "f"];
StringVar Array Group3 := ["g", "h", "i"];
if({MyTable.group} in Group1)
then ("Group1")
else if({MyTable.group} in Group2)
then ("Group2")
else if({MyTable.group} in Group3)
then ("Group3")
else
("Other")

I'm typing that freehand, so forgive the syntax errors. The real formula has none that Crystal finds.

shera4111
 
This isn't really a record selection formula. Do you want users to select a particular set of values? Why not set up the parameter {?group} as a number parameter with values and associated descriptions:

1 a,b,c
2 d,e,f
3 g,h,i

Then set up the selection formula like this:

(
{?group} = 1 and
{table.field} in ["a","b","c"]
) or
(
{?group} = 2 and
{table.field} in ["d","e","f"]
) or
(
{?group} = 3 and
{table.field} in ["g","h","i"]
)

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top