Results 1 to 2 of 2
  1. #1
    dirtbiker1824 is offline Novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    4

    multiple seach critera

    Hi, I'm working on using access to store all of my recipies. I created three tables:

    tblRecipes
    >RecipeID(pk)
    >RecipeName


    >Directions

    tblIngredients
    >IngredientID(pk)
    >IngredientName

    tblRecIng
    >RecIngID(pk)
    >RecipeID(fk)
    >IngredientID(fk)

    because I can have multiple ingredients in each recipe I would like to seach for a recipe that contains certain ingredients. I can do this if I only want to look for one ingredient, but how do I set up my criteria for searching only recipes that contain a specified number of ingrients.
    Example: I only want to display recipies that contain 'onion' & 'carrots' & 'potatos'

  2. #2
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    Doing what you want can be a little tricky. The best way I found to do it is to use an unbound form that has a multi-select list box & a button. Behind the button is some Visual Basic for Application code that dynamically creates a query that in turn, finds the specific recipes with the ingredients. Once the recipes (recipeIDs) are found they can be used to filter a basic form that shows the recipes. I figured that going through the process in a post might be hard to understand, so I created a sample database. When you open the database, you will be presented with a selection form (the unbound form I mentioned). I decide to give you two options, to return those recipes that include all ingredients selected from the list box (as you originally asked in your post) as well as a second option that returns recipes that include any of the selected ingredients.

    The key to getting it to work for all ingredients selected is the query. In your case, you need a nested query. You can see the query I created in the code behind the button.

    If you have any questions, please post back.

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

Similar Threads

  1. Query that would search multiple critera and delete
    By justinwright in forum Queries
    Replies: 2
    Last Post: 08-25-2010, 10:05 AM
  2. Seach table from within a form
    By 95DSM in forum Forms
    Replies: 5
    Last Post: 07-12-2010, 09:43 AM
  3. Replies: 2
    Last Post: 05-25-2010, 02:45 PM
  4. Replies: 5
    Last Post: 12-10-2009, 10:33 PM
  5. Replies: 1
    Last Post: 12-10-2009, 08:41 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