Results 1 to 3 of 3
  1. #1
    chezster1234 is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    May 2013
    Posts
    10

    Suitable way to search different recipe

    hi my name is james and i am rather new to access, i have managed to create a simple mini database but now i am wanting to search for records that are inputted here is my code below i would appreciate any help on this matter.


    what i want it to do is bring a text box up and search the form and if no results are there for your search bring up an error message something along the lines of sorry no record found.

    Code:
    SELECT Juice_db.ID, Juice_db.Flavour_Name, Juice_db.Flavouring_1, Juice_db.Flavouring_2, Juice_db.Flavouring_3, Juice_db.Flavouring_4, Juice_db.Flavouring_5, [Flavour_Name]+[Flavouring_1]+[Flavouring_2]+[Flavouring_3]+[Flavouring_4]+[Flavouring_5] AS NewCol
    FROM Juice_db
    WHERE ((([Flavour_Name]+[Flavouring_1]+[Flavouring_2]+[Flavouring_3]+[Flavouring_4]+[Flavouring_5]) Like "*"+[What Would You Like To Search]+"*"));

  2. #2
    Micron is online now Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,803
    Your sql statement suggests to me that you have designed your db with a spreadsheet mentality/paradigm. Mostly it is the repetition of like things arranged in separate fields and your attempt to bring them together with mathematical operations (+). Apologies if this is not correct, but if you are as new to Access and relational databases as you say, I strongly suggest you research normalization and see if what you have resembles any level of normalization. Even so, you have + signs in places you should not, and seem to be using them where you should not. For example, with respect to flavoring, what is "apple" + "orange" equal to? Even if they are not words but are numbers, what flavor is 3+4? My point is that if you're trying to "string together" words, you don't use the + sign.
    http://rogersaccessblog.blogspot.ca/...on-part-i.html
    Otherwise, what you need is a parameter query (one that prompts you for input) or a query that looks at your form control for a value. Something like
    SELECT * FROM Juice_db.ID WHERE Flavor_Name LIKE & "*" & Forms!frmYourForm.txtPrompt & "*";
    Note: this is constructed as a sql statement like you might have in a query. It's not usable in vba code exactly as written.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    chezster1234 is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    May 2013
    Posts
    10
    ok thankyou for the reply i will lok via the link and thankyou for pointing me in the right direction

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

Similar Threads

  1. recipe file database help to start
    By JohnnyS in forum Access
    Replies: 6
    Last Post: 01-09-2017, 04:27 PM
  2. Access suitable for detailed price list?
    By Wozza in forum Access
    Replies: 3
    Last Post: 01-08-2015, 11:21 AM
  3. Database: From recipe to shopping list
    By schwabe in forum Database Design
    Replies: 3
    Last Post: 05-17-2014, 07:48 PM
  4. Recipe Tables with Master Ingredient List
    By rothian717 in forum Access
    Replies: 4
    Last Post: 09-19-2012, 10:23 AM
  5. Recipe book issues
    By gumberculies in forum Access
    Replies: 2
    Last Post: 10-07-2011, 10:58 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