How to highlight "Filter by Section" field
Access has ApplyFilter Event, which helps us to do this. Here a sample code, which changes border of ActiveControl to red and other controls to default color. And when you remove filter – it will set all controls border color to default.
Private Sub Form_ApplyFilter(Cancel As Integer, _
ApplyType As Integer)
Dim ctl As Access.Control, _
strActiveControl As String
If ApplyType = 1 Then 'Apply filter
strActiveControl = Screen.ActiveControl.Name
End If
If Len(strActiveControl) > 0 Then
Me(strActiveControl).BorderColor = vbRed
End If
For Each ctl In Me.Controls
Select Case TypeName(ctl)
Case "TextBox", "Combobox"
If ctl.Name <> strActiveControl Then
ctl.BorderColor = 8421504
End If
End Select
Next ctl
End Sub

You can extend it by highlighting all controls, participating in filtering, when you apply filter several times.
3 Comments:
I keep getting the 2474 error that states "The expression you entered requires the control to be in the active window."
On line
strActiveControl = Screen.ActiveControl.Name
What am I doing wrong?
perhaps you getting this error when you debugging your code? Then you have to put stop after line:
strActiveControl = Screen.ActiveControl.Name
I am getting this error when running the code from within the form. After applying the filter for search.
Post a Comment
<< Home