Link to home
Start Free TrialLog in
Avatar of Ryan
RyanFlag for United States of America

asked on

Access Textbox Validation w/o VBA

How can I create a simple validation on a textbox using the Validation rules? I was letting the field's rules of the table do it, but evidently the error is too vague for my users to understand.  I can do it with VBA, but seems like this handy Validation Rule would fit here.

I have 2 different textboxes, one is bounded the other not. I just want to require a numeric entry.  I tried in the Validation rule of the textbox "isNumeric([textboxname])" but it throws the message on anything that is entered.  

Seems like such a simple thing, but everywhere I look people resort to VBA.
Avatar of GRayL
GRayL
Flag of Canada image

Select the Format tab of the Properties list, and set Format to General Number.  
Not an answer.  Your validation rule is being interpreted as the literal string: "isNumeric([textboxname])"
Once anyone types anything other than that, the error is thrown.
123abc will fail, abc will fail, 123 will pass, null will pass.
Avatar of Rey Obrero (Capricorn1)
see if this will work for you
place this in the validation rule property

(>=0 And <=99999999) Or Is Null
ASKER CERTIFIED SOLUTION
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Ryan

ASKER

(>=0 And <=99999999) Or Is Null  gives a type mismatch error if i type a letter.  Users won't understand that.

Numeric input mask - never used that before, shall add that to my shopping cart.  Not sure how to implement it though. My number range is:
3.000-50.000 optionally up to 3 decimals.  Theres no message though on incorrect entry just a restriction. This program is used in a very loud area, so the little ding the computer makes won't be heard.

I didn't use quotes when i put isnumeric() I was just setting it off in my sentence.  
well, if you want it clear for your users,

 there is no other way except to use VBA
"just a restriction."

Which forces a numeric input ... which is your requirement.  

On the property sheet for that text box, put you mouse on the Input Mask property ... and hit F1 for full details.

mx
Avatar of Ryan

ASKER

Also using general number gives that same error that users had and didn't understand.  This is used in a factory and some users don't even know what reboot means when you try and troubleshoot over the phone.  Many of the problems occur on midnight shift and theres no supervisors who know how to operator a computer any better. So I'm trying to make this more bullet proof, but also not expand these 50k lines of code.

Am I missing something about this validation thing? Like this seems exactly what it should be used for?
Avatar of Ryan

ASKER

Data Validation allows for any message you put in there. Like "You must enter a number in decimal form" which makes more sense to the user than "The value you entered isn't valid for this field".  They know to put a number, but when they put 34 1/2 they think it crashed and give up. I come in in the morning and get a chewing because theres all these logs no filled out and get to spend the next hour tracking down the information to put in the logs.
Avatar of Ryan

ASKER

Figured it out. Not sure why
in Validation Rule
IsNumeric([tbdim1])=True
works while
IsNumeric([tbdim1]) does not.
what about null values?
Avatar of Ryan

ASKER

I did include that, but this seems so odd to put "=True".  
 (IsNumeric([tbdim1])=True Or True=IsNull([tbdim1]))
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Ryan

ASKER

Any idea why the =true is required?
Isnumeric() is a boolean function
Avatar of Ryan

ASKER

but so is isNumeric()=true
it needs to have the =true because you can have either true or false after evaluating the expression
Avatar of Polishbagpiper
Polishbagpiper

For capricorn1,

A few steps above you said you just needed to hit the Esc key - anyway to have the Enter or Tab in this case function as the Esc?