0

I am pulling in a string and need to decide if it is a number. If it is I want to use that number, if it's not a number I want to print something along the line of "Incorrect input". I have the following so far...

Stringvar Text_Warning;

If NumericText ({OPERATION.USER_8}) 

Then ({GOOD_QTY}*tonumber ({OPERATION.USER_8}))/12

Else 

If NumericText ({OPERATION.USER_8}) = False 

then Text_Warning:= "Entry Missing or Invalid"
Ajay2707
  • 5,690
  • 6
  • 40
  • 58
Penz
  • 1
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Sep 19 '22 at 23:37

2 Answers2

0

IF THEN ELSE logic must return the same data type. The problem with your approach is that you are returning a number in one branch and a string in another.

Solution 1: convert the number in the first branch to a string.

Solution 2: Use 2 formulas and suppress/show one of them depending on the condition.

MilletSoftware
  • 3,521
  • 2
  • 12
  • 15
0

In the formula, always return the same datatype from multiple conditions exists like if-else, so the formula show properly. When you return different different data type, then crystal report confuse, because based on data type you can set formated output like if number, then you can show formated digit etc.

As per your condition, correction needed as

Stringvar Text_Warning;

If NumericText ({OPERATION.USER_8}) Then 

   Text_Warning := Totext ( ({GOOD_QTY}*tonumber ({OPERATION.USER_8}))/12 )

Else 

   Text_Warning := "Entry Missing or Invalid"

Please refer Mat answer in How to compare number and string values contained in the same column

Number to String in a formula field

Ajay2707
  • 5,690
  • 6
  • 40
  • 58