Highlighting Filtered Keywords

Robbyp2001

Registered User.
Local time
Today, 11:19
Joined
Oct 8, 2011
Messages
143
Good Moring Folks

I have a question.

In my library database I have a field entitled 'Summary' within a table called 'SynTitleTbl'. The field is a memo and it contains a summary or synopsis of each book.

My question is this: Is it possible for Access to highlight Key Words within this memo and/or other fields, based on the input from a query? (Perhaps bold or different colour or underlined etc).

The form allows me to search for Author, Title, Series, ISBN no and Key Word. Singly or a combination of any, full word or part of the word.

It works well but when I use the Key Word search, it finds the record/s that contains that word or part word within the memo field [Summary] immediately. Unfortunately these summaries can be quite lengthy and the keyword is difficult to see. Highlighted key word or part-word would be particularly helpful as the anyone browsing can quickly establish of the information is relevant or not.

Currently the records are filters thus:
Form = [SearchPartRecord]
Query = [SearchPartName]
Fields = [Author] [Title] [Series] [ISBN] [Key Word]

Action = Like "*" & [Forms]![SearchPartRecord]![KeyWord] & "*"

I have attached a screen dump of the query in case that helps.

Many thanks

Rob
 

Attachments

  • KeyWordFilter.jpg
    KeyWordFilter.jpg
    69.4 KB · Views: 83
I doubt if you could do this with a query. I assumption is you would need a procedure (VBA), that took user input, assign the input (keywords) to a variable and would use something like Find First to find the keyword within the memo field and then once found, change the attributes of that word.

This is an over simplification of the process; you would need to build in some features to make this work. One thing that comes to mind is a Undo feature so your keywords would not stay highlighted.

If you decide to go down the "VBA Road of Good Intentions", there is plenty of talent in this forum that can help you get this sorted out.

Good luck!
 
To get some bold text in the memo field, you need to use html code <b> and </b>. The control/field property "Text format" must be "Rich Text".

Use the replace function to put in the html code in the text.
But you need also a temp table, because the changes is reflecting back to the table.
Attach is a sample how it can be done.
 

Attachments

Thanks JHB, unfortunately I cannot open this file. Is there any format other than PHP that you could send this?
 
Many thanks JHB. I got it this time. This is exactly what I need. It looks a bit complicated so I'll spend some time to see if I can safely incorporate this into what I already have. Nice work!
 
I don't think it is necessary to create a temporary table.

Assuming the memo field is not to be edited (at least not within the search form) then using JHB's example

1. rename the memofield to say txtMemoField

2. put the following in the txtMemoField controlsource
Code:
=Replace(Nz([MemoField]),Nz([searchtext]),"<b>" & Nz([searchtext]) & "</b>")

3. modify your form recordsource to TheMemoField to work off the original table

4. and the code behind the Search button would just be

Code:
if nz(searchtext)="" then
    me.filteron=false
else
    Me.Filter = "[MemoField] Like '*" & Me.SearchText &"*'"
    me.filteron=true
End if
 
Many thanks to both CJLondon and JHB for your fantastic help with this. Personally I had my doubts as to whether or not such a thing could be done, especially given my personal Access limitations. But once again the solution was out there!
 

Users who are viewing this thread

Back
Top Bottom