Solved

Validating text input into a numeic field

Posted on 2000-05-17
5
239 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

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…
IBM Notes offer Encryption feature using which the user can secure its NSF emails or entire database easily. In this section we will discuss about the process to Encrypt Incoming and Outgoing Mails in depth.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

733 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