Search memo fields by entering multiple search terms in one search

S

Sietske

Hi all!

Hopefully there is someone present who can help me with the following
question.

I'm currently busy with:
I have made a search form for a table with several hundreds of records,
which users can use to search for specific data. When a search field (in this
case the search field txtSummary) is filled in, the content of the field is
compared to all content of the memo field "Summary" in the table, by filling
in a string:

strConditie = "[Omschrijving] Like '*" & txtOmschrijving.Value & "*'"

My current problem:
The memo field "summary" can contain a lot of text. With the method above,
it is not possible to enter more than just one search word which are not in
that exact order.

My question:
How can I deal with the words entered in the search field in such a way that
the record is found in which all the search words are found, whatever the
order of these words? I was thinking of cutting the text, filled in at
txtOmschrijving, by using a "for"-loop, based on the position of spaces in
the filled in text. However, I don't know how to do it.


Thanks in advance for helping me!
 
K

Klatuu

You can use multiple words to search with by using Or between each of the
conditions. It will return rows where any one of the words is found:

strConditie = "[Omschrijving] Like '*" & txtOmschrijving.Value & "*' Or
[AnotherField] Like '*" & txtAnotherField & "*'"
You can add as many as you need.
 
S

Sietske

Hi Klatuu,

I have now used the command "Split", so that I can cut sentences in
txtOmschrijving into single words, and with a "For Each" loop it now fills
each word into strCondition. It's another method and more suitable for what I
wanted to do, but thanks for the hint anyway!

Bye,
Sietske

Klatuu said:
You can use multiple words to search with by using Or between each of the
conditions. It will return rows where any one of the words is found:

strConditie = "[Omschrijving] Like '*" & txtOmschrijving.Value & "*' Or
[AnotherField] Like '*" & txtAnotherField & "*'"
You can add as many as you need.
--
Dave Hargis, Microsoft Access MVP


Sietske said:
Hi all!

Hopefully there is someone present who can help me with the following
question.

I'm currently busy with:
I have made a search form for a table with several hundreds of records,
which users can use to search for specific data. When a search field (in this
case the search field txtSummary) is filled in, the content of the field is
compared to all content of the memo field "Summary" in the table, by filling
in a string:

strConditie = "[Omschrijving] Like '*" & txtOmschrijving.Value & "*'"

My current problem:
The memo field "summary" can contain a lot of text. With the method above,
it is not possible to enter more than just one search word which are not in
that exact order.

My question:
How can I deal with the words entered in the search field in such a way that
the record is found in which all the search words are found, whatever the
order of these words? I was thinking of cutting the text, filled in at
txtOmschrijving, by using a "for"-loop, based on the position of spaces in
the filled in text. However, I don't know how to do it.


Thanks in advance for helping me!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top