Results 1 to 9 of 9
  1. #1
    Join Date
    Sep 2004
    Posts
    10

    Unanswered: More Query questions(either or?)

    I am trying to build a search function where I can search my table for text matches in Either row A Or Row B Or Both rows.

    how would I go about doing this? I can feed the query from a combobox but cant figure out how to do one column or the other or both....

    thanks in advance for your help

  2. #2
    Join Date
    Sep 2004
    Location
    Virginia, USA
    Posts
    98

    Query Question

    Have you tried using an "or" statement for the tables?

    SELECT *
    FROM tablename
    WHERE field1name or field2name Like "*" & [Enter Data Here] & "*";

  3. #3
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Quote Originally Posted by kccpo
    Have you tried using an "or" statement for the tables?

    SELECT *
    FROM tablename
    WHERE field1name or field2name Like "*" & [Enter Data Here] & "*";
    BAD SQL ...

    ... WHERE (( Field1 LIKE '%" & TextA.Value & "%') OR ((Field2 LIKE '%" & TextB.Value & "');"
    Back to Access ... ADO is not the way to go for speed ...

  4. #4
    Join Date
    Sep 2004
    Posts
    10
    no I havent and im not sure how to? I know nothing about and/or statements yet. (I am a newbie learning as I go)

    I have built a form that has 2 items, and a query that has the 2 columns from the table.

    (Item 1) a combobox that has 3 options.
    Search column A
    Search column B
    Search both A & B

    (Item 2) a text box to enter the text to search the columns for.

    I want to be able to select search column A, and type in dog and get all records with the word dog in column A, (or B or both)

    I am lost on making this happen....

  5. #5
    Join Date
    Sep 2004
    Location
    Virginia, USA
    Posts
    98
    Quote Originally Posted by M Owen
    BAD SQL ...

    ... WHERE (( Field1 LIKE '%" & TextA.Value & "%') OR ((Field2 LIKE '%" & TextB.Value & "');"


    Owen, Thanks for the correction...

  6. #6
    Join Date
    Sep 2004
    Posts
    10
    hmm still lost..

  7. #7
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Quote Originally Posted by saw_Duuhst
    hmm still lost..
    Why lost? You have all the elements to build the required search criteria ... Implementing it is another thing ... That you have to do. There are numerous ways for implementing this and only you can specify the way that works best for your needs ...
    Back to Access ... ADO is not the way to go for speed ...

  8. #8
    Join Date
    Jul 2004
    Location
    Southampton, UK
    Posts
    368
    I suspect saw_Duurst isn't familiar with how to execute SQL and is therefore using the query design screen to create queries.

    saw_Duurst:

    The attachment shows how to do OR's i.e. enter criteria on seperate lines. Each line represents a seperate OR.

    The query design screen is an easy way to build SQL (so that you don't have to know about SQL). The buiding of SQL takes place behind the scene. You can view the SQL for a query by clicking View => SQL View. If you create your OR query and view the SQL you will see something similar to what the other posts are suggesting. You can go straight to the SQL view for a blank query and Type/paste the SQL text straight in (if you're good at SQL or are using a solution that's been posted.

    You should really consider buying a good book which will cover the subject of queries thoroughly and provide you with a far more powerful reference. Also, there are some very important concepts to building databases that you simply won't pick up simply by posting questions.

    Chris
    Attached Thumbnails Attached Thumbnails qryOR.jpg  
    Last edited by howey; 09-28-04 at 09:15. Reason: referencing right person

  9. #9
    Join Date
    Sep 2004
    Posts
    10
    thank you howey your right I was unaware of the SQL I thought mostly everything was controled through the design screen.

    While I would love to get a book and really get into it, that option realy is not avalible right now due to $$ issues.

    I also am only writing one access program to fill a personal need (yeah right thats what I said about html, then php lol)

    I do appreciate the advice and help I have been reciving here though. I am very close to being done with my project. (just seems everytime I get "done" I think of something else that would be neat to do)

    thank you for showing the multiple lines I belive that was exactly what I needed.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •