Searching an Access Database

Results 1 to 4 of 4

Thread: Searching an Access Database

  1. #1
    Adam McKee Guest

    Default Searching an Access Database

    I have a form field named "searchfor" and I&#039;m wanting to search an Access database (4 different fields) to see if that word exists. The user has the option to search for the word plainly, or to "match whole word". It&#039;s the "match whole word" that&#039;s getting me.<BR><BR>If I was searching for "Bob", and wanted "match whole word only" I would need to search for "Bob", " Bob ", " Bob", and "Bob " (I know there are many more combinations with punctuation, etc, but let&#039;s just leave it at these to begin with).<BR><BR>How can I do this using a query statement? I thought the following would work to find the word with spaces on either side of it:<BR><BR>ItemName Like &#039; " & Request.Form("searchfor") & " &#039;<BR><BR>however it doesn&#039;t return any records when I do a search for a word I know exists in that field in that table. I even tried the word "and".<BR><BR>Help :) Thanks in advance.

  2. #2
    Steve Cimino Guest

    Default RE: Searching an Access Database

    You need wildcards in there...<BR><BR>ItemName Like &#039;%" & Request.Form("searchfor") & "%&#039;<BR><BR>will return<BR>DedBob<BR>Bobby<BR>Bob<BR>

  3. #3
    Adam McKee Guest

    Default RE: Searching an Access Database

    The problem with that though is that I want users to have the "match whole word only" option... which shouldn&#039;t return "Dedbob" in the results....

  4. #4
    Steve Cimino Guest

    Default RE: Searching an Access Database

    Well, SQL can&#039;t tell the difference between a &#039;d&#039; and a &#039; &#039;, when you&#039;re using a LIKE command.<BR><BR>Why not bring them all back using LIKE and search through the array? At least then you&#039;d have access to the TRIM function...

Posting Permissions

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