Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 16th, 2007, 08:43 AM
Registered User
 
Join Date: Mar 2007
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Want to Search Several Fields for the Same Keyword

I'm a graduate student who has used my limited knowledge of Access to construct a database to organize my notes. I've created three keyword fields that I use to code the contents of each record (1 record=1 note). I'd like to construct a query that will allow me to search all three fields for a particular keyword.

Could anyone fill me in on what the SQL would be for such a query? Again, I want a query that will yield a list of all records in which the keyword appears in any of the three fields.

Reply With Quote
  #2 (permalink)  
Old March 16th, 2007, 08:48 AM
Friend of Wrox
 
Join Date: Oct 2004
Location: Clinton, UT, USA.
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
Default

This would probably be easier to do in the query window, but the SQL would look something like this:

WHERE Field1 LIKE '*' * keyword & '*' OR Field2 LIKE '*' * keyword & '*' OR Field3 LIKE '*' * keyword & '*'

If you are calling the SQL from VBA, you may need to substitute the *'s for %'s

Hope that helps

Mike

Mike
EchoVue.com
Reply With Quote
  #3 (permalink)  
Old March 16th, 2007, 10:53 AM
Registered User
 
Join Date: Mar 2007
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Many thanks, Mike! I didn't think it was possible to do something like this in the query window. Could I trouble you to say a little more about how I'd set it up in the window (I always prefer to avoid SQL when I can)?

Again, real grateful to you.

Best,
E

Reply With Quote
  #4 (permalink)  
Old March 16th, 2007, 11:08 AM
Friend of Wrox
 
Join Date: Oct 2004
Location: Clinton, UT, USA.
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
Default

I'm having trouble thinking of how best to describe it, but here goes...

In access, go to the query tab, and then click "Create a new Query in design view"

THe screen you get will be divided in to, and there will be another window with all of tables listed.

Double click the tables you would like to add, and then click close when you are done.

If you need to set up joins, you can now do it by dragging one field to another, then right clicking and editing the properties to choose the type of join.

Double click any fields you want to return and they will appear down in the bottom section.

Down in the bottom section, you can now add criteria, just in the format

LIKE '*' & 'Keyword' & '*'

Put it on different lines for each field to make it an OR criteria.

Since I suspect that you may need to use SQL anyway, you can now select SQL View from the View menu, and will have the SQL nicely formatted.

There is also a way to have the query prompt you for the variable in the criteria, but I haven't done that for a long long time.

Typically I use this to build my SQL strings, and then transfer them to my code - Heck, I even use it when I need to build SQL for PHP/MySQL apps!

Yell if you need more info,

Mike

Mike
EchoVue.com
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Search by Keyword Grafixx01 Access 10 May 31st, 2007 08:59 AM
Keyword search Echo10 Excel VBA 3 April 23rd, 2006 08:10 AM
Multiple Keyword Search tuffour Classic ASP Databases 3 September 10th, 2004 06:12 AM
highlighting the search keyword(s) Adam H-W Classic ASP Basics 2 February 10th, 2004 09:08 AM
XSLT keyword search help adamr415 XSLT 2 November 12th, 2003 08:44 AM



All times are GMT -4. The time now is 07:47 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.