Solved

Search more than one column in access database using VB.NET

Posted on 2013-06-18
1
790 Views
Last Modified: 2013-09-10
I am trying to do a wildcard search in a MS Access database table.   In the table I want to search two columns for value I am search for.

Here is what I want to do: Search the columns "Title" and "Summary" in the table "tblBooks" for the value 'keyword'.

Something like "SELECT * from tblBooks WHERE Title Like '%Keyword%' AND
Summary Like '%Keyword%'

Not sure what he syntax would be.

Any help would be appreciated.
0
Comment
Question by:Mike_Stevens
1 Comment
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 total points
ID: 39257296
That would be it, except Access uses the asterisk ( * ) as a wildcard. Assuming you have a textbox named "txSearch", which is where the user would enter their search words:

"SELECT * from tblBooks WHERE Title Like '*" & Me.txSearch & " "*' AND
Summary Like '*" & Me.txSearch & "*'"

That would only find records where the value exists in EACH column. If you want to find records where the value exists in EITHER column, us OR:

"SELECT * from tblBooks WHERE Title Like '*" & Me.txSearch & " "*' OR
Summary Like '*" & Me.txSearch & "*'"
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question