Results 1 to 11 of 11
  1. #1
    Serge-Nanaimo is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Feb 2017
    Posts
    5

    Input Mask

    Hi,

    I want to do business card with Phone number and cell number.
    I have the formula to stipulate that if there is no Phone number then choose Cell number as below.

    =IIf(IsNull([PhoneNO]),"Cell: " & [Cell],[PhoneNo] & " Cell: " & [Cell])

    My question is :
    Is there a way that I can input a Mask to see the phone number as (222) 222-2222 vice 2222222222 when using an Iif ?



    Tks.

  2. #2
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    If it's being displayed in a text box and the phone numbers will always be the same format, you could set up a function something like

    Code:
    Function masknumber (phone as integer) as string
    
    masknumber = "(" & left(phone,3) & ")" & mid(phone,4,3) & "-" & right(phone,4)
    
    end function
    Maybe test somewhere that the phone number was the right length too?

  3. #3
    Serge-Nanaimo is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Feb 2017
    Posts
    5
    Hi, thanks for the info.
    Unfortunately I can't get it to work. I never worked with code before, so I'm probably not grasping all the concept of it.

  4. #4
    HiTechCoach's Avatar
    HiTechCoach is offline MS MVP - Access Expert
    Windows 8 Access 2013
    Join Date
    Jul 2010
    Location
    Oklahoma, USA
    Posts
    705
    It can be done by adding format() to the phone numbers using the format string "(000) 000-0000"

    Try:

    Code:
    =IIf(IsNull([PhoneNO]),"Cell: " & Format([Cell],"(000) 000-0000")),Format([PhoneNo],"(000) 000-0000") & "  Cell: " & Format([Cell],"(000) 000-0000"))

    or simplifying your original code to

    Code:
    =Trim(IIf(IsNull([PhoneNO]),"",[PhoneNo]) & "  Cell: " & [Cell])
    would then be

    Code:
    =Trim(IIf(IsNull([PhoneNO]),"",Format([PhoneNo],"(000) 000-0000")) & " Cell: " & Format([Cell],"(000) 000-0000"))
    Boyd Trimmell aka Hitechcoach
    Database Architect and Problem Solver
    Microsoft MVP - Access Expert
    25+ years specializing in Accounting, Inventory, and CRM systems
    "If technology doesn't work for people, then it doesn't work."

  5. #5
    Serge-Nanaimo is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Feb 2017
    Posts
    5
    Works perfect. Thank you very much.
    Serge.

  6. #6
    HiTechCoach's Avatar
    HiTechCoach is offline MS MVP - Access Expert
    Windows 8 Access 2013
    Join Date
    Jul 2010
    Location
    Oklahoma, USA
    Posts
    705
    You're welcome.

    Glad we could assist.
    Boyd Trimmell aka Hitechcoach
    Database Architect and Problem Solver
    Microsoft MVP - Access Expert
    25+ years specializing in Accounting, Inventory, and CRM systems
    "If technology doesn't work for people, then it doesn't work."

  7. #7
    Serge-Nanaimo is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Feb 2017
    Posts
    5
    Hi again,

    Trying to do the same thing but with the Postal Code in a query.

    Expres1: [Address ] & " " & [City] & ", " & [StateOrProvince] & ", " & Format([PostalCode ],"L0L 0L0")

    For some reason it doesn't leave a space in the middle of the Postal Code.

    Tks in adv.

  8. #8
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    Not sure it's possible in a query. What about checking if the 4th digit is a space and then inserting one if it isn't

    Or better to check data at source?




    Sent from my iPhone using Tapatalk

  9. #9
    HiTechCoach's Avatar
    HiTechCoach is offline MS MVP - Access Expert
    Windows 8 Access 2013
    Join Date
    Jul 2010
    Location
    Oklahoma, USA
    Posts
    705
    Quote Originally Posted by Serge-Nanaimo View Post
    Hi again,

    Trying to do the same thing but with the Postal Code in a query.

    Expres1: [Address ] & " " & [City] & ", " & [StateOrProvince] & ", " & Format([PostalCode ],"L0L 0L0")

    For some reason it doesn't leave a space in the middle of the Postal Code.

    Tks in adv.


    What you are using trying to use is an input mask for a textbox control. This doesn't work the same for the Format().

    Try:
    Code:
    Expres1: [Address ] & " " & [City] & ", " & [StateOrProvince] & ", " & Format([PostalCode ],">@@@ @@@")
    Boyd Trimmell aka Hitechcoach
    Database Architect and Problem Solver
    Microsoft MVP - Access Expert
    25+ years specializing in Accounting, Inventory, and CRM systems
    "If technology doesn't work for people, then it doesn't work."

  10. #10
    Serge-Nanaimo is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Feb 2017
    Posts
    5
    Tks Boyd,

    Works great.
    :-)

  11. #11
    HiTechCoach's Avatar
    HiTechCoach is offline MS MVP - Access Expert
    Windows 8 Access 2013
    Join Date
    Jul 2010
    Location
    Oklahoma, USA
    Posts
    705
    You're Welcome.

    Glad we could assist.
    Boyd Trimmell aka Hitechcoach
    Database Architect and Problem Solver
    Microsoft MVP - Access Expert
    25+ years specializing in Accounting, Inventory, and CRM systems
    "If technology doesn't work for people, then it doesn't work."

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Input Mask
    By kdbailey in forum Access
    Replies: 4
    Last Post: 12-19-2014, 08:11 AM
  2. Input mask
    By scorpion99 in forum Access
    Replies: 4
    Last Post: 02-21-2014, 02:18 AM
  3. input mask
    By slimjen in forum Forms
    Replies: 7
    Last Post: 10-07-2013, 03:20 PM
  4. Input Mask
    By qbc in forum Access
    Replies: 2
    Last Post: 01-20-2012, 03:27 PM
  5. Input mask
    By doobybug in forum Access
    Replies: 2
    Last Post: 06-17-2009, 09:40 PM

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