Dagz200
Dagz200

Reputation: 211

Crystal Formula to exclude if value does not contain a certain format

I'm trying to exclude any value from a certain field (table.value) that does not match this format AA#####A. Example if they entered APT12345T, or PT12345PT and No Value then I want to exclude it from the report. It needs to match example AP12345P. What selection formula can I use to accomplish this. Any help is greatly appreciated Thanks in advance.

Upvotes: 0

Views: 3196

Answers (1)

Beth
Beth

Reputation: 9607

try reading Crystal's help topics on the mid() and isnumeric() functions.


here's an example from the help file:

Examples The following example is applicable to both Basic and Crystal syntax:

Mid("abcdef", 3, 2)

Returns "cd".

so, in your case, you want to strip your value into three pieces,

mid(table.value,1,2)
mid(table.value,3,5) 
mid(table.value,8,1)

and build up a three-part boolean variable where:

  1. the first piece is not numeric(), or between 'AA' and 'ZZ', or however else you want to test for letters,
  2. the second part isnumeric(), and
  3. the third part passes the same test as the first part.

where are you getting stuck?


something like this:

not isnumeric(mid({table.field},1,2)) and
isnumeric(mid({table.field},3,5) and
not isnumeric(mid({table.field},8,1))

Upvotes: 1

Related Questions