473,387 Members | 3,750 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Code to get phone numbers in canonical format?

I have a (Access 2003) contact management database where the user can
double-click a contact's phone number in a form and have the Windows Phone
Dialer dial the number. The problem is the number has to be in canonical
format or dialing rules won't be applied (cf. MSKB Article 318575). I don't
want to use an Input Mask because users like to put comments after the
number, like: "985-983-0098 ext. 980 - Mike B."

I thought there might be a function or other canned code to put a phone
number into canonical format - i.e. +1 (985) 983-0098. ???

If not, I'll need to brush up on regular expressions and gin something up on
my own...

Thanks in advance.
Nov 13 '05 #1
3 9989
How about having separate fields on your form for Area Code, Number and
Extension? If your data entry form is a single form, these three textboxes
could be unbound with your real telephone number field hidden. You could
then concatenate the telephone number from the AfterUpdate event of each of
these in case the user changed any one of them and set your hidden bound
telephone number equal to the concatenated number.

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdatasheet.com
www.pcdatasheet.com
"deko" <de*****@hotmail.com> wrote in message
news:K9******************@newssvr29.news.prodigy.c om...
I have a (Access 2003) contact management database where the user can
double-click a contact's phone number in a form and have the Windows Phone
Dialer dial the number. The problem is the number has to be in canonical
format or dialing rules won't be applied (cf. MSKB Article 318575). I don't want to use an Input Mask because users like to put comments after the
number, like: "985-983-0098 ext. 980 - Mike B."

I thought there might be a function or other canned code to put a phone
number into canonical format - i.e. +1 (985) 983-0098. ???

If not, I'll need to brush up on regular expressions and gin something up on my own...

Thanks in advance.

Nov 13 '05 #2
> How about having separate fields on your form for Area Code, Number and
Extension? If your data entry form is a single form, these three textboxes
could be unbound with your real telephone number field hidden. You could
then concatenate the telephone number from the AfterUpdate event of each of these in case the user changed any one of them and set your hidden bound
telephone number equal to the concatenated number.


Well, it's a subform datasheet and users like the free-form, in-cell
editing/commenting of the numbers. The best way to do it, I think, is just
grab whatever string is in the field, parse it into the right format, and
send it to the dialer, transparent to the user. I'm sure someone has
already written the code I need... so I thought I'd ask...
Nov 13 '05 #3
here's a first crack at it:

Dim i As Integer
Dim n, p As String
strDial = Trim$(Forms!frm0!frm0Telephone.Form!TelNumber)
For i = 1 To Len(strDial)
n = Mid(strDial, i, 1)
If n Like "#" Then p = p & n
Next i
strDial = "+1" & Format(Left(p, 10), "(@@@)&&&-&&&&")
Debug.Print strDial

-------

Assumes an area code (and nothing else) is prefixed to every phone number.
should probably strip out any leading 1 or 0...
Nov 13 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: TP | last post by:
Hi, In SQL Server 2000, if I have to create a table to store a very large number of 10 digit telephone numbers, would I be better off to have a bigint field or just use a varchar field? If I do...
2
by: MLH | last post by:
Using A97, I have tables with 10-char text phone number fields to allow entry of xxxyyyyyyy phone numbers - where xxx is the 3-digit area code and yyyyyyy is the 7-digit phone number. I wish to...
1
by: seash | last post by:
Hi I need a regular expresssion which validates any kind of Phone numbers format..irrespective of the Country need hel ---seash
4
by: Earl | last post by:
I'm curious if there are others who have a better method of accepting/parsing phone numbers. I've used a couple of different techniques that are functional but I can't really say that I'm totally...
2
by: jfshaw | last post by:
Hey everyone, Sorry if this is a stupid question, but I can't find the answer. I need to query a list of phone numbers where the format is ########## and have the results show any rows that...
4
by: lilOlMe | last post by:
I'd love to be able to validate phone numbers in my software but my product is being used world wide. Not everyone's phone number is formatted like USA/Canada formats theirs. I've found a few...
5
by: lim4801 | last post by:
I am currently in doing a program which is given by my tutor: Contemplate that you are working for the phone company and want to sell "special" phone numbers to companies. These phone numbers are...
4
by: Blue Streak | last post by:
Hello, Folks! Does anyone know of a website that lists the local phone number formats for each country? TIA...
7
by: Propoflady | last post by:
My contacts can have as many as five or six phone numbers - is it possible to make a query that puts the name, and each phone number after it on the same line - for this reason I have two tables -...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.