SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Mar 2002
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question How would I define an appropriate query for a keyword search in Access?

    Newbie question:

    I am building a form within Access with a Search function. I need to allow for three words or less to search. I need a Query to find the records associated with each word in the search box inputted by User. Currently, I have one field with multiple keywords for each record. How would I define an appropriate query within Access or an SQL statement to be used in Access?

    Thanks!

  2. #2
    SitePoint Addict danfran's Avatar
    Join Date
    Jan 2005
    Location
    New York City
    Posts
    244
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    x,

    The short answer is: Use VBA to split the search-text on the space character. Then, go through the resulting array and figure out how many terms were entered. Next, craft a SQL statement like:

    select * from tableA where [Description] like '%blue%' or [Description] like '%sweaters%' or [Description] like '%navy%'

    Finally, bind this recordset to whatever form control you're using in Access.


    Unfortunately, your 'question' is rather complicated and I'm not so sure you'll get a lot of replies here as there is no 'easy answer' or single way to do it.

    Dan


Bookmarks

Posting Permissions

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