Results 1 to 10 of 10
  1. #1
    Lynnemcc87 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2014
    Posts
    6

    Parameter Query Help Needed

    I am currently creating a database at my work which holds details of over 200 companies. I was wondering if there is any possible way to create a parameter query that returns ALL or PART of the company name that is being searched for.

    for example.

    The parameter query at the minute prompts the user to 'Enter Company Name'.....if I were to type in 'Royal Bank of Scotland' it will return the records for this company, which is great! However, if I type in 'Royal Bank' then it does not return any search results



    We also have alot of company departments on our database as they all have different contacts. For example, we have records such as: Falkirk Council Home Enery Advice Team, Falkirk Council Housing, Falkirk Council Healthier Lives......so if i wanted to pull up ALL of the records that have Falkirk Council as part of their company name, then it doesnt work and the search comes up blank becaue there are no companies that are only called Falkirk Council.

    If anyone is able to help me on this then that would be great and very much appreciated!

  2. #2
    rivereridanus is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Jun 2011
    Posts
    71
    Absolutely. You can just use a wildcard such as *. If you are writing your own SQL string for that search, then you can just do something like "SELECT * FROM [datasource] WHERE [name] LIKE *" + [whatever is in your textbox] + "*;"

    The * on both sides will allow you to search any part of that field.

  3. #3
    Lynnemcc87 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2014
    Posts
    6
    Thanks so much for getting back to me on this and letting me know that this can be done!

    However, I'm slightly confused as to where I write the string that you suggested above. Do i write this in the criteria box in the query design under the field 'Company'? I'm a good user of Access but unfortunately I am not at an advanced level Also, which parts of the string do i amend by writing in my own criteria? the database is quite simple, the table is called Contacts and the field that I want to be able to search in is called Company.

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Quote Originally Posted by Lynnemcc87 View Post
    ...The parameter query at the minute prompts the user...
    As mentioned in post #2, employ the LIKE operator and the Wildcards.

    Since your query object is requesting the user input, open your query and switch to SQL view. Locate the statement for the parameter. Change the = sign to LIKE and add the wildcards as described in post #2.

  5. #5
    Lynnemcc87 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2014
    Posts
    6
    Thanks, thats helps, I switched it to the SQL view and changed the = to LIKE.....im still not getting anywhere with it though. Im getting confused with the order in which I should write it all and where I should enter my own text. It keeps coming up with an error message basically saying that what I'm writing is incorrect

  6. #6
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Go ahead and post the SQL that was previously working here.

  7. #7
    Lynnemcc87 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2014
    Posts
    6
    Sorry, was on my lunch break.

    WHERE (((Contacts.Company)=[Enter company name]));

    That is the SQL that was working when you eneter the full name of the company.

    Thanks!

  8. #8
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    I forgot that the input box does not have quotes in the SQL statement so I added them here. Basically, have to concatenate the wildcards to the input box.

    WHERE (((Contacts.Company)like"*" & [Enter company name] & "*"));

  9. #9
    Lynnemcc87 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2014
    Posts
    6

    Thumbs up

    Quote Originally Posted by ItsMe View Post
    I forgot that the input box does not have quotes in the SQL statement so I added them here. Basically, have to concatenate the wildcards to the input box.

    WHERE (((Contacts.Company)like"*" & [Enter company name] & "*"));
    Thanks very much! The parameter query now works! This will make things so much easier for my team when using and searching through the database!

    Again, Thanks so much for your help, it is very much appreciated


  10. #10
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Not a problem and welcome to the forum.

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

Similar Threads

  1. Help needed : Library catalogue in access format is needed
    By dealers in forum Sample Databases
    Replies: 3
    Last Post: 01-16-2014, 02:03 PM
  2. Replies: 12
    Last Post: 06-25-2013, 12:52 PM
  3. Query help needed
    By mclovin in forum Queries
    Replies: 4
    Last Post: 04-09-2012, 10:22 AM
  4. HELP NEEDED! Enter Parameter Value
    By lpfluger in forum Queries
    Replies: 4
    Last Post: 03-27-2011, 04:38 PM
  5. Query help needed on a one to many sum
    By devphreak in forum Queries
    Replies: 3
    Last Post: 02-25-2011, 10:49 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