Solved

Validating text input into a numeic field

Posted on 2000-05-17
5
232 Views
Last Modified: 2013-12-18
Hello,

Ive got a validation question for you.

On a form I want to validate that the value entered into a numeric field is actually a numeric.

Ive looked at the input validation section but that only seems to check on a save. I need to check as soon as someone leaves the field.

So...what Ive done is put some script into the Exiting event.

Ive got this...

Sub Exiting(Source As Field)
     
     Dim ws As  New NotesUIWorkspace
     Dim doc As NotesDocument
     
     Set uidoc = ws.CurrentDocument
     Set doc = uidoc.document
     
     If (Isnumeric(doc.annualdays(0)) = True) Then
          End
     Else
          Msgbox "You must enter a numeric value for this field",48,"Numeric Field Error"
     End If
End Sub


Now this works ok if you have a space or number in the field, but if you put a character in - 'a' for instance, then the script generates an error to the effect of "Variant does not contain a container"

Obviously this isnt an ideal error message for users...

Does anyone know how I can accomplish this?

Many thanks,

Mat
0
Comment
Question by:prenexus
  • 2
  • 2
5 Comments
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 2819789
Hi Mat

The numeric fields always validate for numeric values, this is the default behavour, if it is a text value  then it will prompt u with the error message.

For that you must enable "automatically refresh field" in the form properties. If u do so then user is prompted with error msg saying that the value is incorrect.

Good luck
~Hemanth

0
 
LVL 2

Accepted Solution

by:
Antonysingh earned 100 total points
ID: 2823700
Hi prenexus,

Use a error handler in your code as shown in the following code, this will handle the error.

Dim ws As  New NotesUIWorkspace
      Dim doc As NotesDocument

       'Error handler
      On Error Goto errhand

      Set uidoc = ws.CurrentDocument
      Set doc = uidoc.document
      
      If (Isnumeric(doc.annualdays(0)) = True) Then
            End
            
      End If

'Error handle section.
      
errhand:
      Msgbox "You must enter a numeric value for this field",48,"Numeric Field Error"
      Call uidoc.gotofield("annualdays")
      Exit Sub


Hope this may help you.
Good luck,

-Antony.
0
 

Author Comment

by:prenexus
ID: 2823773
HemanthaKumar,

Thanks for the answer - and while it does provide a solution its not really what I was looking for.

Thanks,

Mat
0
 

Author Comment

by:prenexus
ID: 2823777
Antony,

Thanks for the comment! Thats exactly what I was looking for.
Whats more youve shown me a way to highlight the field that was causing the trouble as well.

Mat
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 2827908
That's OK.

May be I don't know the whole picture, and Antony got it.

~Hemanth
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

For Desktop Techs: How to retain a user's Notes configuration data when swapping out the end user's computer. (Assuming that you are not upgrading to a completely different version of Notes client) All you need to do is: 1) install Notes o…
Lack of Storage capacity is a common problem that exists in every field of life. Here we are taking the case of Lotus Notes Emails, as we all know that we are totally depend on e-communication i.e. Emails. This article is fully dedicated to resolvin…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now