Solved

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

Posted on 2013-06-18
1
707 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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…

771 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now