PC Review


Reply
Thread Tools Rate Thread

How to Convert data to Phone Number format?

 
 
SinCity
Guest
Posts: n/a
 
      5th Oct 2006
I have a table that contains some data like this...

Phone_Numbers
212-560-5602
212-587-2938

And I have an Excel document that contains data like this...

phone_numbers
(211) 787-3957
(217) 827-2999

How can I import the Excel data into the Access Database so that they are
treated
both as phone numbers? I also do not want to allow duplicates.

Please help!



 
Reply With Quote
 
 
 
 
Bill Mosca, MS Access MVP
Guest
Posts: n/a
 
      5th Oct 2006
Run an update like this:

Update MyTable
Set [PhoneNum] = Replace(Replace([PhoneNum],"(",""),") ","-")

The inside Replace is removing the left paren. The outside Replace removes
the right paren and space.

You might want to store just the numbers and use formatting and input masks
for the user. That way you stay flexible as to how th enumber displays.

--
Bill Mosca, MS Access MVP


"SinCity" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
>I have a table that contains some data like this...
>
> Phone_Numbers
> 212-560-5602
> 212-587-2938
>
> And I have an Excel document that contains data like this...
>
> phone_numbers
> (211) 787-3957
> (217) 827-2999
>
> How can I import the Excel data into the Access Database so that they are
> treated
> both as phone numbers? I also do not want to allow duplicates.
>
> Please help!
>
>
>



 
Reply With Quote
 
SinCity
Guest
Posts: n/a
 
      6th Oct 2006
Bill,

Forgive me (I'm a newbie).....but how exactly do I run the following command
that you suggested?


Update MyTable
Set [PhoneNum] = Replace(Replace([PhoneNum],"(",""),") ","-")


If you wouldn't mind telling me what to point and click on I would
appreciate it.
(Access 2003)

Thx,
Mark




"Bill Mosca, MS Access MVP" <(E-Mail Removed)> wrote in message
news:uq$(E-Mail Removed)...
> Run an update like this:
>
> Update MyTable
> Set [PhoneNum] = Replace(Replace([PhoneNum],"(",""),") ","-")
>
> The inside Replace is removing the left paren. The outside Replace removes
> the right paren and space.
>
> You might want to store just the numbers and use formatting and input
> masks for the user. That way you stay flexible as to how th enumber
> displays.
>
> --
> Bill Mosca, MS Access MVP
>
>
> "SinCity" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>>I have a table that contains some data like this...
>>
>> Phone_Numbers
>> 212-560-5602
>> 212-587-2938
>>
>> And I have an Excel document that contains data like this...
>>
>> phone_numbers
>> (211) 787-3957
>> (217) 827-2999
>>
>> How can I import the Excel data into the Access Database so that they are
>> treated
>> both as phone numbers? I also do not want to allow duplicates.
>>
>> Please help!
>>
>>
>>

>
>



 
Reply With Quote
 
Bill Mosca, MS Access MVP
Guest
Posts: n/a
 
      6th Oct 2006
No problem, Mark.

Open a new query in design view. When the box pops up to pick a table, close
it without picking anything. Click on View>SQL view.

Paste what I gave you into the blank window.
Change MyTable to the name of your table.
Change PhoneNum to the name of your phone field.
Click the ! icon to run the query.

--
Bill Mosca, MS Access MVP


"SinCity" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Bill,
>
> Forgive me (I'm a newbie).....but how exactly do I run the following
> command that you suggested?
>
>
> Update MyTable
> Set [PhoneNum] = Replace(Replace([PhoneNum],"(",""),") ","-")
>
>
> If you wouldn't mind telling me what to point and click on I would
> appreciate it.
> (Access 2003)
>
> Thx,
> Mark
>
>
>
>
> "Bill Mosca, MS Access MVP" <(E-Mail Removed)> wrote in message
> news:uq$(E-Mail Removed)...
>> Run an update like this:
>>
>> Update MyTable
>> Set [PhoneNum] = Replace(Replace([PhoneNum],"(",""),") ","-")
>>
>> The inside Replace is removing the left paren. The outside Replace
>> removes the right paren and space.
>>
>> You might want to store just the numbers and use formatting and input
>> masks for the user. That way you stay flexible as to how th enumber
>> displays.
>>
>> --
>> Bill Mosca, MS Access MVP
>>
>>
>> "SinCity" <(E-Mail Removed)> wrote in message
>> news:%(E-Mail Removed)...
>>>I have a table that contains some data like this...
>>>
>>> Phone_Numbers
>>> 212-560-5602
>>> 212-587-2938
>>>
>>> And I have an Excel document that contains data like this...
>>>
>>> phone_numbers
>>> (211) 787-3957
>>> (217) 827-2999
>>>
>>> How can I import the Excel data into the Access Database so that they
>>> are treated
>>> both as phone numbers? I also do not want to allow duplicates.
>>>
>>> Please help!
>>>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
SinCity
Guest
Posts: n/a
 
      9th Oct 2006
Hi Bill,

Thanks again for your past post. It worked beautifully. I am making some
other changes to my database that are similar to the one that you helped me
with. Would you mind helping me understand the following statement?

Set [PhoneNum] = Replace(Replace([PhoneNum], "(" , "" )," ) "
,"-")

Your syntax does seem to work, but it also seems a little different then the
syntax I found on the web.

Thanks much!




 
Reply With Quote
 
Bill Mosca, MS Access MVP
Guest
Posts: n/a
 
      9th Oct 2006
We're using a replace function inside of another replace function. I did
that because we have 2 pieces of the original string that need work. The
open parenthesis must be removed and the closed paren and one space must be
replaced with a dash.

When you nest functions, the inside one is run first, then the outside one.
There is no real order necessary here. Either function could have been on
the inside. If I used one function at a time, I would need to run 2 separate
queries.

Replace is a built-in function with 3 parameters.
1. The string you want to change.
2. The piece you want changed.
3. The piece you want the change to be.

In the inside Replace function:
Replace([PhoneNum], "(" , "" )

[PhoneNum] is the string.
( is the character to search for.
An empty string (2 double quotes with nothing in the middle) is what we want
put in. In other words, we want to replace an open parenthesis with nothing.
So "(555) 555-1235" becomes "555) 555-1234"

Once the open paren is removed, we can replace the close paren and one space
with a dash. Now "555) 555-1234" becomes 555-555-1234.

That help?

--
Bill Mosca, MS Access MVP


"SinCity" <(E-Mail Removed)> wrote in message
news:u27S$(E-Mail Removed)...
> Hi Bill,
>
> Thanks again for your past post. It worked beautifully. I am making some
> other changes to my database that are similar to the one that you helped
> me
> with. Would you mind helping me understand the following statement?
>
> Set [PhoneNum] = Replace(Replace([PhoneNum], "(" , "" )," ) " ,"-")
>
> Your syntax does seem to work, but it also seems a little different then
> the
> syntax I found on the web.
>
> Thanks much!
>
>
>
>



 
Reply With Quote
 
SinCity
Guest
Posts: n/a
 
      11th Oct 2006
>
> That help?
>
> --
> Bill Mosca, MS Access MVP


Thanks Bill. Your explanation was awesome! Yes that helped.


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert a phone number Jim Microsoft Excel Misc 3 29th Dec 2009 07:59 PM
convert phone format Rusty Microsoft Excel Misc 3 20th Aug 2009 05:44 AM
convert phone number andrewm Microsoft Excel Misc 4 18th Jan 2009 10:22 PM
Convert number to phone number smartgal Microsoft Excel Misc 1 16th Oct 2008 11:48 PM
how do I add phone number format as a permanent custom format? frustratedagain Microsoft Excel Misc 3 4th Feb 2006 03:52 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:43 AM.