Solved

IsNumber() not available for Validation Rules

Posted on 2011-09-20
7
578 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
[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
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 47

Expert Comment

by:Dale Fye (Access MVP)
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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
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 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 500 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 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 36574283
Glad to help,

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

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

734 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