Results 1 to 5 of 5
  1. #1
    heather034 is offline Novice
    Windows 8 Access 2013
    Join Date
    May 2015
    Posts
    3

    Search criteria

    I have created a form where you enter a single digit of the first number of an area code and when you click the run query button all results of an area code beginning with the digit entered will be displayed. The problem I am having is that I can not figure out the correct syntax to put in the search criteria under the phone number field in my query. The area codes either start with a 1 or a 2. What would I put in the search criteria to do this? Thank you.

  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
    If you want to use dynamic parameterized query, review: http://www.datapigtechnologies.com/f...tomfilter.html

    Method I prefer: http://www.allenbrowne.com/ser-62.html
    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
    heather034 is offline Novice
    Windows 8 Access 2013
    Join Date
    May 2015
    Posts
    3
    Okay, so I looked at both of your suggestions and I was able to get the query to register what I type into the text box and display results that contain the number I entered. However, for example, if I enter 1 into the form, it displays all of the phone numbers containing 1 or 2 however I only need it to display the results based on the first digit of the area code that I entered, either 1 or 2.
    For example, if there is a phone number in the field that is 123-465-7890 and I entered 1 into the search form, that phone number should be one that is displayed because the first digit of the area code is 1. How do I make a search criteria for begins with to get this? I am using this:

    Like ("1*") Or ("2*") & [forms]![MyFormName]![TextBox]

  4. #4
    CJ_London is online now VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,929
    I think what you want is

    WHERE phonenumber Like [forms]![MyFormName]![TextBox] & "*"
    Last edited by CJ_London; 05-26-2015 at 03:01 AM. Reason: got the wildcard in the wrong place

  5. #5
    heather034 is offline Novice
    Windows 8 Access 2013
    Join Date
    May 2015
    Posts
    3
    Quote Originally Posted by Ajax View Post
    I think what you want is

    WHERE phonenumber Like [forms]![MyFormName]![TextBox] & "*"
    Thanks! It's working now.

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

Similar Threads

  1. Replies: 1
    Last Post: 03-26-2015, 11:08 AM
  2. Search Form - Dialog box asks for search criteria
    By faythe1215 in forum Queries
    Replies: 3
    Last Post: 02-10-2015, 05:54 PM
  3. Replies: 3
    Last Post: 01-04-2015, 06:09 PM
  4. Search Criteria
    By Meccer in forum Forms
    Replies: 1
    Last Post: 04-01-2011, 12:53 PM
  5. Search By Criteria - Flexible Criteria Fields
    By lilanngel in forum Access
    Replies: 0
    Last Post: 03-16-2011, 06:25 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