Page 2 of 2 FirstFirst 12
Results 16 to 19 of 19
  1. #16
    templeowls is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2019
    Posts
    305
    Quote Originally Posted by Micron View Post
    Yes, good point. That's what happens when I rush and have had no coffee yet. I'm about to take care of that right now. So more like?
    Code:
    s = Replace(s, "-", " ")
    s = Replace(s, ")", "")
    s = Replace(s, "(", "")
    s = Replace(s, "+", "")
    
    If InStr(s, "x") > 0 Then s = Left(s, InStr(s, "x") - 1)
    ExtractPhoneNum = s
    Note that I dropped the string variable as it's not needed.
    Thanks! That works for me.

    One final question...for cells that have no phone number and are blank, this process adds a zero to those cells. If possible, I'd prefer them to remain blank. Any suggestions on how to do that? Should the query have some sort of 'if not null' statement? Or is there a better way to do that?

  2. #17
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,793
    perhaps
    myQueryCalculatedField:IIF(ExtractPhoneNum([otherField])="","",ExtractPhoneNum([otherField])
    Probably would have to see your query design and/or sql. The field must be a text field otherwise you couldn't have those characters in the values, and the function should return "" if no value is passed so I can't see why your query creates zeros. Unless maybe you're using some other function as a wrapper.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #18
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,412
    this process adds a zero to those cells
    you are not using the process outlined by micron - the zero is caused by the val function which he is not using

    learn to use the immediate window to test what you are doing. Val returns 0 when the value is a zls

    you don't need the val function which returns a number and will give you a funny result if there are 16 or more characters - because you are storing as a string

    ?cstr(val(""))
    0

    ?cstr(val("1234567890123456"))
    1.23456789012346E+15

    drop the val function and use another replace to replace the spaces with a zls

  4. #19
    templeowls is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2019
    Posts
    305
    Thank you!!!

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. User Guide
    By yagerlegi in forum Access
    Replies: 5
    Last Post: 10-14-2014, 02:36 PM
  2. Help or Guide to Particular Form Setup
    By Zephyx in forum Forms
    Replies: 2
    Last Post: 06-27-2013, 03:53 PM
  3. Someone to help me understand a guide
    By carrybag93 in forum Access
    Replies: 4
    Last Post: 06-04-2012, 12:20 AM
  4. VBA & VBA GUI Guide?
    By bginhb in forum Programming
    Replies: 2
    Last Post: 04-01-2012, 08:39 AM
  5. plz guide about access
    By ali zaib in forum Access
    Replies: 3
    Last Post: 01-10-2012, 11:25 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums