Hi,
I have 3 fields - field1, field2 & field3. Field1 and field2 is number type. Field3 is field2 - field1
When I enter any alphabet and click on other field, I get error in field3 → Cannot convert text to number. But when I goto other field thru Tab then it say text cannot be allowed and the focus is in that field.
How to achieve both the functionalities without having the error message in field3?
Subject: Compute after validation not working
One way, in Field3:
@if( @IsError(@TextToNumber(field1) | @IsError(@TextToNumber(Field2); 0; field2-field1)
Subject: RE: Compute after validation not working
Hi,
Did you try entering nos after that, the field3 still shows 0. Am I missing something over here
Subject: RE: Compute after validation not working
I enter the code from the top of my head and had a mistake and forgot to say you change Field1 and Field2 to Text:
f1 := @TextToNumber(field1);
f2 := @TextToNumber(field2);
@if( @IsError(f1) | @IsError(f2); 0; f2-f1)
Subject: RE: Compute after validation not working
Nope still not working. If there is any other option pls let me know i will check back around 7:00PM
Subject: RE: Compute after validation not working
What is not working? I actally tried it worked fine for me?
With Field1 and Field2 as text you can enter anything without getting an error.
If the two values are entered as number it calc the difference in field 3.
Subject: RE: Compute after validation not working
I noticed I never checked:
Is this for the Notes Client or on the web?
Are you looking for “excel like” updates. I type in number and field 3 instantly updates?
Here are print screens when I did it with the client and refreshed:
Is that what you wanted to see?
Subject: RE: Compute after validation not working
In your second screenshot if you noticed first field is nothing and next field is 10. So field1 should be 10 as nothing should automatically become 0. That is what is not working. Try changing nothing to some number but still field3 is 0. Hope you understood what I am trying to say
Subject: RE: Compute after validation not working
If I understand, want to treat the value as zero if invalid. OK. Does this work better then:
f1 := @TextToNumber(field1);
f1 := @if( @IsError(f1); 0; f1);
f2 := @TextToNumber(field2);
f2 := @if( @IsError(f2); 0; f2);
f2-f1
One intersting thing I discovered is if Field1 is “19hello” it will return 19. I’m guessing you DON’T want that either?
To handle that, I did the following (I haven’t tested this so you might want to see what happens if you enter 19.00000 for example)
f1 := @TextToNumber(field1);
f1 := @if( @IsError(f1); 0; @Length(@Text(f1))<>@Length(field1); 0; f1);
f2 := @TextToNumber(field2);
f2 := @if( @IsError(f2); 0; @Length(@Text(f1))<>@Length(field1); 0; f2);
f2-f1
As we all know, the more you try and “Idiot proof” your application… they build a better idiot. 