Solved

Access query to analyse telephone number

Posted on 2013-12-23
6
330 Views
Last Modified: 2013-12-23
Hello,

I need to run a query over a database with a telephone number field.

Some of these columns have had text added to them, such as "ext".

I need to find these but cannot use IsNumeric as many of the numbers have a space between the area code and the number.

Is there a function or expression which will show those columns where any of the characters are not either a number or a space.

Thanks
0
Comment
Question by:Petermcg001
6 Comments
 
LVL 57
ID: 39735923
You can use:

 InStr([<field>],"ext")

with a check of:

> 0

Jim.
0
 
LVL 57
ID: 39735932
Sorry, focused on the extention.  

You can use Instr() to also search for  (, ), or +  (international calling).

That would be the simplest.  You could write a IsNumeric() type function to check the string byte by byte.

Is this a one time clean-up task or an on-going thing?

Jim.
0
 
LVL 1

Author Comment

by:Petermcg001
ID: 39735956
Hello Jim,

Thanks for looking at this.  Basically it could be any letter that has been used - people have been adding notes on the end of the number.  I don't think IsNumeric will work - for instance  the telephone number 0123 123456 is OK but isnumeric detects the space as a problem.

So basically I need a query that flags the record if the telephone number contains anything other than 0123456789 or a space.

It's a one-off.

Thanks
0
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
LVL 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 500 total points
ID: 39736111
how about something like:

WHERE [phonenumber] Like "*[a-z,A-Z]*"
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39736115
place this codes in a  regular module

function ValidateTelNo(strTel as string) as boolean

ValidateTelNo=True
dim j as integer, vtel as string, num as string
num=" 0123456789"

if strTel & ""="" then ValidateTelNo=false: exit function

vtel=strtel

for j= 1 to len(vtel)
     if instr(num, mid(vtel,j,1)) then
         'do nothing
         else
         'found a non numeric character
          ValidateTelNo=false
         exit for
      end if
next

end function


to use in your query

select [TelNo], ValidateTelNo([TelNo]) From tablename


.
0
 
LVL 1

Author Closing Comment

by:Petermcg001
ID: 39736197
Thanks, works fine.  I added "!-/" so ended up with  "Like *[a-z,A-Z,!-/]*"
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
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…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

831 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