Using a form to search keywords in a memo field

It is based on your original post, so it is supposed to go into a query
 
In a new field or in the memofield where the keywords are searching? If the latter, then the code returns all records if a kw is left blank, because I tried it that way.
 
What about this solution ?
"Unlimited" numbers of keywords, a single text box, not 10, easy to code and more... :)
 

Attachments

in a new column for the bulk of the code and >0 is put in the criteria. You can also untick the show button
 
Mihail:
That worked really well, thank you! Now I have to figure out how to display the records on the report that ideally would have the highlighted search words in the reported field. Can I pass the input keywords through a query that would allow for them to be highlighted in the report?
 
Mihail:
That worked really well, thank you! Now I have to figure out how to display the records on the report that ideally would have the highlighted search words in the reported field. Can I pass the input keywords through a query that would allow for them to be highlighted in the report?
1)
The actual approaches (all of them) allow you to find a string in your memo field.
Example:
MemoField = "I ornate my Christmas tree"
Key = "or"
Actual code will say that this record should be included in your search results because the "or" string is founded in the MemoField:
"I ornate my Christmas tree".
In order to find only words is necessary more code. A lot more.

2)
MemoField = "I ornate my Christmas tree"
Key1 = "ornate"
Key2 = "tree"
Actual code will find the "ornate" keyword, will decide "Yes, this record is good" and will go to the next record without to check if the "tree" keyword is or is not in the MemoField
Using other words, now you use an OR in order to decide if a record should be included in the search results. The code say to access something like this:
"Select this record if, in the MemoField, you can find Key1 OR if you can find Key2 OR Key3 and so on".
The actual code can be easy adapted in order to have an AND between keywords.
"Select this record if, in the MemoField, you can find Key1 AND Key2 AND Key3 and so on"

3)
In order to display formatted text in a text box you must set the Text Format property to Rich Text. Easy to done: Property Sheet -> Data tab -> Text Format.

But you need to format the text before to be displayed in the text box.
For this, Access use HTML tags (labels) in the text. So you need code to insert in your MemoField text this tags:

MemoField = "I ornate my Christmas tree"
Key1 = "ornate"
Key2 = "tree"
TextWithTags = "I <b>ornate</b> my Christmas <b>tree</b>"
This will be displayed: I ornate my Christmas tree

So, in order to highlight the keywords:
1) Find all instances in the MemoField for each keyword where the keyword is a word in MemoField, not a part of word.
2) Insert HTML tags before and after the words that you founded in step 1)

Are you sure that you are able, based on your skills, to accomplish this tasks ?

Good luck !
 

Users who are viewing this thread

Back
Top Bottom