Textbox validation

carl6885

Registered User.
Local time
Today, 03:16
Joined
Nov 16, 2011
Messages
82
Hi

I have a form with a text box on where a user can enter a value. Providing that value is in the right format it will change it.

For example if the user enters 5 or 5,1 they will get the following output when exiting:

5 year(s) or 5 year(s), 1 month(s).

What I need to do is ensure the user enter either a number or number comma number into the box otherwise they are alerted and bounced back to the textbox.

Anyone got any ideas how I could do this?

Thanks in advance.

Carl
 
Work through it step by step. You are essentially parsing text which means you will need to use some string functions. Here's a link to a helpful site of common functions: http://www.techonthenet.com/access/functions/

I wouldn't even try to write code, I'd try to write a paragraph in english about what needs to happen to the input string to make sure it complies. Something like:

Test if there is a comma in the input. If there is see if a number comes before and after the comma, if not see if the input is a number. Etc, Etc.

Cover every condition and once it reads right translate your paragraph into code.
 
Hi

Thanks for the reply.

I have code that checks for a comma and if not it warns as the client wanted, initially the latter option above. They have since they want to be able to just write 5 if 5 years rather than 5,0.

The bit I am struggling on is how I allow for both scenarios...

Thanks

Carl
 

Users who are viewing this thread

Back
Top Bottom