Results 1 to 6 of 6
  1. #1
    noaccessguru is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Melbourne, Australia
    Posts
    68

    Can you use wildcards in parameter queries?

    Hi guys,
    I have a question about parameter queries. I would like to use a parameter query where the user can type in a search string in a parameter query. I know that to make the query ask for the criterion, you enter a question in square brackets in the query design window. E.g. for a database of Materials, you can enter this as a criterion for Raw Material name:

    [Enter Material Name] (ie - Sugar) and this will bring back all the records that match exactly to 'Sugar' only

    I know you can also put in Like *Sugar* and it will bring up all the Materials that contain the word 'Sugar' in it (ie Sugar Syrup, Brown Sugar etc)

    But that is hardcoded into the query - I would like to know how to do that in a parameter query, so that the user can enter a word or part of a word and it will bring back all the records that contain that word or few letters???

    So it will prompt them to enter a word or first few letters etc and it will bring back all the records.

    ie, enter 'Sug' and it will bring back all the records that contain those letters (Sugar, Sugar Syrup, Brown Sugar etc)


    Hopefully that makes sense

    Any help appreciated!

    Thanks

  2. #2
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    Use something like this in your query criteria.

    Code:
     Like [Enter * for all or first four letters of last name and *]
    Or
    Code:
    Like [Enter first four letters of last name] & "*"
    Alan

  3. #3
    noaccessguru is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Melbourne, Australia
    Posts
    68
    Hi Alan,

    Thanks heaps for that! Have used the 2nd option and it works well!

    Appreciate your help!

    Thanks again

  4. #4
    noaccessguru is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Melbourne, Australia
    Posts
    68
    Hi Alan,

    If I have text boxes where the user can enter in a word and I want it to bring back ALL the records that CONTAIN that word, how do I set my criteria for this?
    I want to hard code this into my query....(so that the user doesn't have to enter in the asterisks themselves in the text box, ie - *sugar*)

    below is the criteria I am using, but this only brings back records that START with whatever is entered into the Text box.

    Like [Forms]![Frm_MaterialsSearch2].[tbProduct] & "*"


    Any help would be great.

    Thanks again

  5. #5
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    Try this.

    Like "*" & [Forms]![Frm_MaterialsSearch2].[tbProduct] & "*"

    Alan

  6. #6
    noaccessguru is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Melbourne, Australia
    Posts
    68
    Thanks a million Alan!

    That worked!

    Appreciate it...
    Last edited by noaccessguru; 05-24-2011 at 08:45 PM. Reason: Spelling

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

Similar Threads

  1. Parameter Queries & Reports
    By Nixx1401 in forum Reports
    Replies: 6
    Last Post: 05-07-2011, 08:09 PM
  2. parameter queries
    By cpride in forum Access
    Replies: 1
    Last Post: 03-23-2011, 09:21 PM
  3. Using wildcards (*) in SQL
    By SIGMA248 in forum Queries
    Replies: 1
    Last Post: 07-22-2010, 08:44 PM
  4. Running parameter queries from VBA
    By John Southern in forum Programming
    Replies: 6
    Last Post: 03-25-2010, 10:24 AM
  5. Wildcards?!
    By esx_raptor in forum Access
    Replies: 3
    Last Post: 02-19-2010, 03:22 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