Results 1 to 4 of 4

Thread: Access: convert data type from text to a number HELP!!

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2002
    Posts
    8

    Access: convert data type from text to a number HELP!!

    Ok I created a access database a long time ago, crm type database but due to poor decision making at the time I have stored phone numbers in a text data type but the data has come from a mask edit textbox in the format of: (00) 0000 0000

    So I want to convert it to a plain number field but need to workout how?

    Someone please help..

  2. #2
    Frenzied Member
    Join Date
    May 2006
    Location
    some place in the cloud
    Posts
    1,886

    Re: Access: convert data type from text to a number HELP!!

    IMO You could develop a conversion routine:
    1.- Copy the table (now it's the old table)
    2.- Change field data type to numeric in new table
    3.- Read from old table/field
    4.- Remove unwanted characters
    5.- Write new table/field

    Now, I have developed a lot of applications and always used telephone number field as string with no problem at all... it's only one more field of information

    Let's wait the experts' opinion

    JG

  3. #3

    Thread Starter
    New Member
    Join Date
    Jun 2002
    Posts
    8

    Re: Access: convert data type from text to a number HELP!!

    if I want to just keep it as a string but remove all the formatting eg ( ) _ what sql command do I need to run to change them all.

    if I run:

    SELECT Replace(Replace(Replace(Replace(phone,"(",""),"_",""),")","")," ","") FROM tblClients;

    it displays the number the way I want it to but how do I make the changes?

    use the Update command?

  4. #4
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Access: convert data type from text to a number HELP!!

    Something like this.
    Code:
    UPDATE tblClients SET phone =Replace(Replace(Replace(Replace(phone,"(",""),"_",""),")","")," ","")
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width