I have a form that users search using Filter By Form. Some of the users, however, get confused trying to figure out when the filter is on and when it is not. So my idea was to have a little label pop up when the form was being filtered. After searching and searching, I finally found this bit of code and adapted it to my form. I put it in the form's On Timer event and set the timer interval to 100.
Private Sub Form_Timer()
' Makes the label flash when a filter
' has been applied so the user knows a filter
' is being used.
If Me.Filter <> " " Then
' Find out what the current color is
' and change it to the other color
' so it looks like the label is flashing.
If Me.lblFilter.ForeColor = 0 Then
Me.lblFilter.ForeColor = 255
Else
Me.lblFilter.ForeColor = 0
' Change the caption.
Me.lblFilter.Caption = "FILTERED"
End If
Else
' No filter exists so make the label static.
Me.lblFilter.Caption = "UnFiltered"
Me.lblFilter.ForeColor = 0
End If
The problem is, this code makes the word FILTERED flash red when the filter has been applied (which is good) but when you click on the Search button to start a new Filter by Form, the word FILTERED still appears, although it does not flash. I am a beginner at VBA and try as I might, I cannot figure out why this does this. My "Search" cmd button, btw, applies filter by form and clears the grid. I don't know if this has something to do with my problem.
Thanks for any suggestions you might have and sorry this is long-winded.
Private Sub Form_Timer()
' Makes the label flash when a filter
' has been applied so the user knows a filter
' is being used.
If Me.Filter <> " " Then
' Find out what the current color is
' and change it to the other color
' so it looks like the label is flashing.
If Me.lblFilter.ForeColor = 0 Then
Me.lblFilter.ForeColor = 255
Else
Me.lblFilter.ForeColor = 0
' Change the caption.
Me.lblFilter.Caption = "FILTERED"
End If
Else
' No filter exists so make the label static.
Me.lblFilter.Caption = "UnFiltered"
Me.lblFilter.ForeColor = 0
End If
The problem is, this code makes the word FILTERED flash red when the filter has been applied (which is good) but when you click on the Search button to start a new Filter by Form, the word FILTERED still appears, although it does not flash. I am a beginner at VBA and try as I might, I cannot figure out why this does this. My "Search" cmd button, btw, applies filter by form and clears the grid. I don't know if this has something to do with my problem.
Thanks for any suggestions you might have and sorry this is long-winded.