Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

IsNumber() not available for Validation Rules

Posted on 2011-09-20
7
Medium Priority
?
582 Views
Last Modified: 2013-11-29
I'm trying to validate that characters 2 through 5 of a table's text field should be numeric. However, IsNumeric() doesn't seem to be available (Access 2003).
0
Comment
Question by:Milewskp
7 Comments
 
LVL 10

Expert Comment

by:Michael Vasilevsky
ID: 36569960
IsNumeric should work in VBA and in a SQL statement. What do you mean it doesn't seem to be available? What are some strings you're trying to validate?

MV
0
 
LVL 75
ID: 36570185
VBA:

If IsNumeric(Mid(sFldText, 2, 4)) Then
   ' what ever

Query:

SELECT IsNumeric(Mid([FIELD1],2,4)) AS Expr1
FROM Table1;

or

SELECT IIf(IsNumeric(Mid([FIELD1],2,4)),"Yes","No") AS Expr1
FROM Table1;

mx
0
 
LVL 49

Expert Comment

by:Dale Fye
ID: 36570937

Or you could use something like:

SELECT * FROM yourTable WHERE [yourField] not like "?[0-9][0-9][0-9[0-9][0-9]*"

This will identify all records where the first character allows any character, then the next 5 characters are numeric, and then has any number of other characters.  The NOT will identify any records that violate this rule.

I'm not certain whether this is available in the Validation, but could be used in the BeforeUpdate event to test the value in the control.
0
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
LVL 1

Author Comment

by:Milewskp
ID: 36573507
I should have been more clear: I was trying to use IsNumeric() in the Validation Rule property of a table's text field. It didn't work, and when I clicked Build, I discovered that IsNumeric is not included in the list of built-in functions. Therefore I assume it's not avaialble for validation rule properties (even though it may be avaiable in VBA and SQL).
0
 
LVL 49

Accepted Solution

by:
Dale Fye earned 2000 total points
ID: 36573547
try:

Validation Rule: Like "?[0-9][0-9][0-9][0-9][0-9]*"

0
 
LVL 1

Author Comment

by:Milewskp
ID: 36574267
Thanks fyed, you're a genius.
0
 
LVL 49

Expert Comment

by:Dale Fye
ID: 36574283
Glad to help,

I generally prefer to put my validation tests in the Form_BeforeUpdate
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

916 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