Results 1 to 12 of 12
  1. #1
    indians207 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Nov 2013
    Posts
    10

    How to exclude an area code in a phone number?

    I'm working with several phone numbers, and five area codes. I'd like to exclude one of these area codes and only show the other four.



    I'm trying to exclude "614" and I've tried a couple different things but can't seem to get it.

    Thanks!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Are area code and phone in the same field? Is there parens around the area code? You want to exclude all records with area code 614?

    Try:

    SELECT * FROM Table WHERE Not PhNum Like "614*";
    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.

  3. #3
    indians207 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Nov 2013
    Posts
    10
    The phone numbers are like this: (###) ###-####
    Table is Membership , Title is "HomePhone"

    Would something like this work?
    Not Like "(614#)" ?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    No.

    SELECT * FROM Table WHERE Not Like "(614)*";
    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.

  5. #5
    indians207 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Nov 2013
    Posts
    10
    Syntax is incorrect?

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Sorry, I forgot the field.

    SELECT * FROM Table WHERE Not PhNum Like "(614)*";
    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.

  7. #7
    indians207 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Nov 2013
    Posts
    10
    I ran : SELECT * FROM [Membership] WHERE Not HomePhone Like "(614)*"; and still got invalid syntax. Am I doing some stupid mistake or something?

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Okay, I had to go build query to refresh memory. If you used the Access query builder it would get the syntax correct for you.

    SELECT * FROM Membership WHERE HomePhone Not Like "(614)*";
    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.

  9. #9
    indians207 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Nov 2013
    Posts
    10
    I think I found the problem, in my builder there is no "Select". I'm running the same version as you though so I don't know what's going on. I can just run it normally and go back and delete the 614s. Thanks for the help though, I appreciate it

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Open query builder and select tables from the list, drag fields to the grid, type parameters on Criteria row. Switch to SQL View to see the code.
    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.

  11. #11
    indians207 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Nov 2013
    Posts
    10
    I only see an Elements and Categories list and tables isn't in either of them

    Edit- Found it, I put in:

    Membership]![HomePhone] Not Like "(614)"

    But it still came up with 614


    Is this the code you meant?
    SELECT Membership.FName, Membership.LName, Membership.City, Membership.State, Membership.HomePhone
    FROM Membership
    WHERE (((Membership.HomePhone)=[Membership]![HomePhone])) OR (((Membership.HomePhone)=[parameters]));

  12. #12
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Where are you seeing Elements and Categories?

    Where are you trying to construct this?

    Yes, that is SQL statement.
    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. Clean Phone Number data
    By pkstormy in forum Code Repository
    Replies: 0
    Last Post: 03-11-2013, 10:24 AM
  2. Texas City,State,Zip and Area Code
    By burrina in forum Sample Databases
    Replies: 0
    Last Post: 11-12-2012, 10:35 PM
  3. Unbound Phone Number Not Formating
    By Huddle in forum Access
    Replies: 3
    Last Post: 02-13-2012, 05:10 PM
  4. Phone number format
    By ManvinderKaur in forum Access
    Replies: 1
    Last Post: 06-24-2010, 08:07 AM
  5. Phone number in (000) 000-0000
    By Ajay in forum Queries
    Replies: 9
    Last Post: 03-12-2010, 11:50 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