Solved

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

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

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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

632 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