Results 1 to 9 of 9
  1. #1
    sknechte is offline Novice
    Windows 10 Access 2016
    Join Date
    Jan 2018
    Posts
    14

    Specified numbers in a query

    I have an access query with a list of customer phone numbers. I only want to show the ones from a certain area code. How do I go about doing this?

  2. #2
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Depends what the format of the phone number is. If it is a text field with numbers only (for instance), have a field in the query with xxx:Left(PhoneNumber,3) - and then in the criteria line put your area code.

  3. #3
    sknechte is offline Novice
    Windows 10 Access 2016
    Join Date
    Jan 2018
    Posts
    14
    (###) ###-####

  4. #4
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    So a field that is defined as: Left(PhoneNumber,5) has in the criteria line : ="(123)"

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    So are the () and - and space actually saved in the data? Are you using Mask property for data entry? Is the mask set to save the () and - and space characters?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    sknechte is offline Novice
    Windows 10 Access 2016
    Join Date
    Jan 2018
    Posts
    14
    That is correct. I was trying "Like 212" because that's how I did it with zip codes, but that must not be right.

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    LIKE is meaningless without wildcard, might as well use =.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  8. #8
    sknechte is offline Novice
    Windows 10 Access 2016
    Join Date
    Jan 2018
    Posts
    14
    Well it was put in as *212, and it turned into "like 212" and nothing was visible in the data sheet view

  9. #9
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Query syntax would be like:

    SELECT * FROM table WHERE PhoneNumber LIKE "(212)*";

    That assumes the () are actually in the data and not just display format.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 2
    Last Post: 08-30-2017, 07:11 AM
  2. Replies: 1
    Last Post: 03-17-2017, 06:08 PM
  3. Replies: 5
    Last Post: 02-26-2016, 10:48 AM
  4. Replies: 8
    Last Post: 03-10-2014, 11:47 AM
  5. Replies: 1
    Last Post: 11-29-2011, 08:43 AM

Tags for this Thread

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