473,386 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Keyword Search

I am trying to write a query that will allow a partial word search.

I know that if I have something along the lines of

SELECT TblName.Name, TblName.Category, TblName.Type,
TblName.Ingredients, TblName.Instructions
FROM TblName
WHERE (((TblName.Name) Like [Keyword Search]));

then this will allow the user to type in their keyword and have the
results bring back anything that is an exact match.

In SQL I would use like %red% to find anything that contained the
string red. How do I do a Like search of ths nature in Access, keeping
in mind that I still want the user to be able to type in their string.

I have tried a number of varients using % and * but nothing working....

Thanks in advance!

Feb 9 '06 #1
6 5658
Perhaps you can put some extra wild card characters
in your WHERE clause:

WHERE (((TblName.Name) Like "*" & [Keyword Search] & "*"));

This should help you in the right direction.

Regards

Feb 9 '06 #2
Tried this:

WHERE [Name] Like "*" & [Keyword Search] & "*"

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)
PieOPah wrote:
I am trying to write a query that will allow a partial word search.

I know that if I have something along the lines of

SELECT TblName.Name, TblName.Category, TblName.Type,
TblName.Ingredients, TblName.Instructions
FROM TblName
WHERE (((TblName.Name) Like [Keyword Search]));

then this will allow the user to type in their keyword and have the
results bring back anything that is an exact match.

In SQL I would use like %red% to find anything that contained the
string red. How do I do a Like search of ths nature in Access, keeping
in mind that I still want the user to be able to type in their string.

I have tried a number of varients using % and * but nothing working....

Thanks in advance!

Feb 9 '06 #3
PieOPah wrote:
In SQL I would use like %red% to find anything that contained the
string red. How do I do a Like search of ths nature in Access, keeping
in mind that I still want the user to be able to type in their string.


What Inkman and MGFoster have suggested work and I have no variation on
that.

What I would suggest, however, is possibly an alternative way to the way
you are doing, ie, a means by which your results are changed as the user
types in a keyword. I use it quite frequently and successfully, but if
anyone else sees anything fundamentally wrong or dangerous with it,
hopefully they will speak up! 8)

For this, on your form you need two text boxes. Say the first is
UNBOUND and is called "txtSearchEnter" and is visible and indeed is the
text box in which a user types in a keyword. The second is also unbound
and we'll call it "txtSearch" and it's visible property is set to NO.

Set the rowsource of a list box or the record source for a subform the
same as what inpen or MGFoster wrote... in this case:

SELECT Name, Category, Type, Ingredients, Instructions
FROM TblName
WHERE Name Like "*" & [Forms]![frmWithAboveTextBoxes].[txtSearch] & "*"

Note - I wouldn't use "Name" as a table field name - it's an Access
reserved word that could well cause you lots of grief.

In the on change event of txtSearchEnter, set up the following VBA - I
am using a list box called "lstResults". lstResults has the above
described row source. The syntax will vary a little if you use a
subform instead:

Private Sub txtSearchEnter_Change()

Me.txtSearch.Value = Me.txtSearchEnter.Text

Me.lstResults.Requery

End Sub

It's important that the text property is used. What this does is use
whatever is typed in txtSearchEnter in the where clause.

As I said, I've used this a number of times successfully. I uaully
include a button that clears stuff, ie, with the event procedure like so:

Private Sub btnClear_Click()

Me.txtSearchEnter.Value = Null

Me.txtSearch.Value = Null

Me.lstResults.Requery

End Sub
--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Whatcha doin?" - Ditto "TIM-MAY!!" - Me
Feb 9 '06 #4
Thank you all for your help :) This certainly makes things much easier
for me :D

Feb 10 '06 #5
Thanks for the advise on t he field name :) I have adjusted this and
was pleasnatly supprised when all of my forms and queries automatically
updated themselves.

I was expecting a big job going through everything having to manually
change it :D

Feb 10 '06 #6
PieOPah wrote:
Thanks for the advise on t he field name :) I have adjusted this and
was pleasnatly supprised when all of my forms and queries automatically
updated themselves.

I was expecting a big job going through everything having to manually
change it :D


I hate to be a wet blanket, but the reason the names changed was because
Access comes with Name Autocorrect on. I moved up from A97 late in the
game and took it as a best practice from the folks here to turn Name
Autocorrect Off - the common name for here is "Autocorrupt" an
apparantly it has some awful side effects at some point.

Allen Browne discusses this on his Access Tips web pages. See
http://allenbrowne.com/bug-03.html

What I have done to do the same sort of thing you've described is using
Rick Ficher's Find & Replace: http://www.rickworld.com/

You can try it for a little while for free and if, like I did, you find
it an indispensable tool, $35 USD is not much to cough up for it.

--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "What's UP, Dittoooooo?" - Ditto
Feb 11 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Torfi Sackbatten | last post by:
Hi Everyone, I´m asked to "speed up" a keyword search based on MySQL. The material i´m given to work with is a quite large MySQL table with 1.5 mio rows, defined something like: CREATE TABLE...
4
by: Axel | last post by:
Is it possible to write a Stored Procedure that takes a string of search keywords as argument and returns the recordset? At the mo I am passing the WHERE String as argument. I got this...
4
by: geetha | last post by:
Dear all, I have a database with all the research capabilities of professors of a university. I need to implement a "keyword search" feature in my welcome page which will actually work like a...
2
by: rlemusic | last post by:
Hi everybody, I’m creating a database in Access (I believe it’s 2000) to catalogue items in the archives of a small museum. I’m a total n00b as far as using Access goes, but by looking at some...
12
by: paitoon | last post by:
Hi, I got a little bit problem about search result in my site. When i put the keyword and click on search ....everything work fine i got the correct result but they not order by the keyword,but...
3
by: Redbeard | last post by:
Hi All this is my first time post, be gentle. I am looking at creating a keyword search that searches multiple fields in a Form and then filters records that match the keyword. The Form...
5
by: kanley | last post by:
I have a main table with a text description field. In this field, its populated with a string of data. I need to identify from this string of data the name of the vendor using some keywords. I...
1
by: prasath03 | last post by:
Hi Gurus, I am doing one website project that project contains one search module. In that search page i have entered the keyword to search. If i want to search the keyword with "any keyword" or...
1
by: alamodgal | last post by:
hiiiiiii I have a problem in highlighting searching keyword.Actually im using this function for searching Public Function HighLight(ByVal Keyword As String, ByVal ContentFor As String) Dim...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.