473,569 Members | 2,352 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Categor y, TblName.Type,
TblName.Ingredi ents, TblName.Instruc tions
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 5670
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:::mgf0 0 <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.Categor y, TblName.Type,
TblName.Ingredi ents, TblName.Instruc tions
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]![frmWithAboveTex tBoxes].[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.Va lue = Me.txtSearchEnt er.Text

Me.lstResults.R equery

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.txtSearchEnt er.Value = Null

Me.txtSearch.Va lue = Null

Me.lstResults.R equery

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 "Autocorrup t" 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
2714
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 datarecords ( id BIGINT(20) NOT NULL auto_increment, , keywords TEXT NOT NULL,
4
9664
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 technique from an Extreme Ultradev tutorial by Rick Curtis it looked quite ok: http://www.princeton.edu/~rcurtis/ultradev/tutorial12.html I have to...
4
1572
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 query generator and search my entire database for the keyword entered by the user and show up table/form that has the keyword searched for. Please...
2
2661
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 online tutorials and how the museum’s existing collections catalogue is set up in Access, I’ve been able to come up with a basic database that suits the...
12
2968
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 they order by the alphabet.....some and the problem is happen sure if there are many result to display...the real result that people put keyword for...
3
5385
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 currently has a button that connects to a Query that run the keyword search in several field and then filters the results. The problem is that I can not do a...
5
3361
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 have another table that contains 2 fields, one being the keywords to search for from the string of data and the other field being the vendor name...
1
3131
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 "all keyword" after searched the records are showed. what i expecting is i want to hightlight the all keyword in that page with case insensitive. I...
1
2772
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 objHighLight As New highlight(Keyword, "<span class='searchKeyword'>{keyword}</span>") ContentFor = objHighLight.process(ContentFor, False,...
0
7618
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7926
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8132
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7678
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6286
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3656
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3644
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1226
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
944
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.