Example Apps for Businesses, Schools & Developers

Version 1.2          Approx 0.9 MB (zipped)                 First Published 14 Nov 2023

This is the fourth in a series of articles about highlighting objects on Access forms.

In this article, I will explain how you can highlight the search matches in both forms and reports.

Almost fifteen years ago, I used this idea to improve the appearance of a search feature in our School Data Analyser application.

This is a very large application with several thousand objects:

SDA Objects
Keeping track of the many objects became a significant task for our developers as the application continued to grow over the years
As a result, I implemented a powerful Database Object SQL Search feature for myself and other developers to locate objects when required.
It could also be used to Find & Replace specified text in selected objects.

For example, in the screenshot below, a search was done for all queries whose SQL contains 'Active' and 'DOB' (date of birth)
Of the 1552 queries, the search found just 2 queries with both text strings. It took 55 seconds to complete.

SDA SQL Search
Selecting an object from the search results list, opens a new form with (in this case) the query SQL in which the search strings are highlighted.

Search Results Form
It is also possible to view the SQL for one or all objects in the list in a report where once again the search strings are highlighted

Search Results Detail Report

So, how is the search match highlighting done?
First of all, the query SQL is read:

Query SQL
Next, this is saved as rich text and code is used to format each instance of the search string in bold red text with yellow highlighting:

Query SQL Rich Text
For example, the use of rich text (HTML) tags mean the string: Active is replaced by Active

The idea for the highlighting in this feature was loosely based on Allen Browne's article Highlight Search Matches
In the example, any of the three form fields can be searched and the search string is highlighted.

Search Highlight Form AJB

Here are an example of the results obtained:

Search Highlight Form AJB 1
This is done using a rich text box overlaying the selected field with a rich text equivalent of the field contents highlighting the search string
The form design shows the rich textbox in grey

Search Highlight Design AJB
For further information and all code, please see Allen Browne's article Highlight Search Matches


This short video (0:17) shows the effect in action:


The example database is a slightly modified version of that available on Allen Browne's website

Click to download:   Search Highlight v1.2.accdb     Approx 0.45 MB (zipped)

Download and unblock the zip file.
For more details, see my article: Unblock downloaded files by removing the Mark of the Web

Unzip and save the ACCDB file to a trusted location.

Related Articles:

      Highlight Current Record in Continuous Form

      Highlight Current Control

      Highlight Required Fields


Please use the contact form below to let me know whether you found this article interesting/useful or if you have any questions/comments.

Please also consider making a donation towards the costs of maintaining this website. Thank you

Colin Riddington           Mendip Data Systems                 Last Updated 14 Nov 2023

Return to Example Databases Page

Return to Top