I am working on a document searching program. Can I
highlight some words which were searched keywords in a
label or text box.
Depending on how you want the highlight to appear, you could use a
function like the following...
==================
Public Function IndicateEdit(Optional lngColor As Long = 14342874)
'Changes the back color (to light grey by default) and back style
'of a text box to normal, ie not transparent.
'Intended to be used in the after update event for the control.
Screen.ActiveControl.Backcolor = lngColor
Screen.ActiveControl.BackStyle = 1
End Function
==================
In the control that you want to highlight call the function. Use the
After Update event.
=IndicateEdit()
Note that you can select all the controls that you want at the same
time and put this in the properties window - Event tab.
Now to set them back you could use the following procedure.
======< watch word wrap >========
Public Sub ResetCtls(strName As String, Optional lngColor As Long =
11333375)
'Sets the back color (to a sandy yellow by default) and back style
'of text and combo boxes to transparent.
Dim ctl As Control
Dim frm As Form
Set frm = Forms(strName)
For Each ctl In frm.Controls
If ctl.ControlType = acTextBox Or _
ctl.ControlType = acComboBox Then
ctl.Backcolor = lngColor
ctl.BackStyle = 0
End If
Next ctl
Set frm = Nothing
End Sub
==================
Call with the form's name.
BTW, these are both in a standard module.
- Jim