I have form validation in the QuerySave event. I run through a number of text fields checking they have been filled in. I also have a number field which if the number entered is greater than 10000 should throw up a error.
How can I do this? I tried to use Int but I’m getting ‘Type mismatch’ error when I try this.
If (source.FieldGetText(“txtValidate”) ) = “1” Then
If Len (source.FieldGetText(“nmFinancial” )) = “” Then
If Int (source.FieldGetText(“nmFinancial” )) > 10000 Then
Messagebox “To proceed you must enter how you want the performance variance to change”, 16, “”
If you want to check whether a text field has been populated you do not need the Len statement. Use
if(Source.FieldGetText(“nmFinancial”) = “”)
Also the highest value an integer can hold is 32767 so you will receive an overflow error if it is higher than this. You will also receive a type mismatch error if a user has entered a non numeric value in the field like 10002M.
Test the field for a valid numeric value using IsNumeric and then use CLng to test whether value is over 10000.
you are using the wrong function to convert your text into a number. You want Cint, not Int. Also, Len does not return a value that can be compared to “” which is technically a string value. Also, according to the Notes help:
In LotusScript Release 3 and after, Len(NULL) generates an error. In previous releases of LotusScript, Len(NULL) returned NULL.
To address this, i would probably grab the back end document and do a test to see if the NotesItem is Null. Then I would do my number check.