Connecting Tech Pros Worldwide Help | Site Map

filter or query based on user input

Newbie
 
Join Date: Jul 2006
Posts: 1
#1: Jul 13 '06
Hello...

I'm REALLY new to this whole thing, so if you all don't mind speaking in lamens terms for me... What I want to do seems like it should be simple, but I've been searching everywhere and I can't come up with anything. Here's the deal.

I have 4 categories in a table, one of which is "products" where there are multiple entries, I want to create a search which will find one specific product based on a users input. Say for example:

Company A offers keychains, lanyards and hats.
Company B offers shirts and hats
Company C offers only keychains.

I'd like to create a textbox in a seperate form where I can type in "keychains", click search and it will return all the information pertaining to Companies A and C. or if i were to input "hats", get info on Compaines A and B.

Do I use a filter, a Query... I really don't know how to do it... It seems like it could be so simple, but apparenlty everything has to be incredibly difficult with Access... I don't see why I can't type in something comparing the value of Text9 to the text contained in the Products Column in the criteria box of a filter or query... apparently this requires some kind of code... where do I put the code anyway? Any light that could be shed would be so incredibly appreciated. If anyone has different approach, I'm open to ideas as well.

Thanks,
Ed
best answer - posted by comteck
You are on the right track with creating a query. If I understand you correctly, the data that is in the product field of the table are lanyards, shirts, hats, etc. If this is correct, then what you have to do is create a query for the table that has the product field (for ex. the name of the query could be qryProduct). When you create a new query, the list of tables will appear. Just double click on the table, and it will appear in the upper portion of the query.

Drag down into the query all the fields you want to appear on your form. Then, on the bottom, you will see a box called "Criteria". Under "Product", in the Criteria box, type the following:

[Enter Product]

Close and save the query. Then, on the form itself, open the properties and in the Record Source, assign the query (in this case "qryProduct") to the form. To open the properties, go into design view, and right click on the little black square in the upper left corner.
Familiar Sight
 
Join Date: Jun 2006
Location: Edmonton, AB
Posts: 179
#2: Jul 13 '06

re: filter or query based on user input


You are on the right track with creating a query. If I understand you correctly, the data that is in the product field of the table are lanyards, shirts, hats, etc. If this is correct, then what you have to do is create a query for the table that has the product field (for ex. the name of the query could be qryProduct). When you create a new query, the list of tables will appear. Just double click on the table, and it will appear in the upper portion of the query.

Drag down into the query all the fields you want to appear on your form. Then, on the bottom, you will see a box called "Criteria". Under "Product", in the Criteria box, type the following:

[Enter Product]

Close and save the query. Then, on the form itself, open the properties and in the Record Source, assign the query (in this case "qryProduct") to the form. To open the properties, go into design view, and right click on the little black square in the upper left corner.
Newbie
 
Join Date: Oct 2009
Posts: 1
#3: Oct 11 '09

re: filter or query based on user input


Hello,

Sorry for bumping such an old thread but I'm trying to produce a query almost identical to the above solution. Using the above question and solution as an example what I want to be able to do is replace the text input box that pops up with a combo box holding all of the items in the 'Products' part of the table to allow the user to pick any of the products in the table, eliminating the possibility of entering an item does not exist resulting in the query returning an empty datasheet.

Many thanks in advance for any help reagrding this matter.
Reply