Solved

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

Posted on 2013-06-18
1
766 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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Suggested Solutions

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…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

832 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