Solved

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

Posted on 2013-06-18
1
820 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

710 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