assign a filter to a toggle control

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a filter 'myProdString' called from my Filter function as below.

Function myFilter()
DoCmd.ApplyFilter "myFilter", myProdString
End Function

I have added a toggle button to my form which I want to apply the myFilter
function when its pressed and turn off the filter when its unpressed.

1) Which event on the toggle do I use to call myFilter?

2) What code and event do I need to turn it off?

Rgds,

Bruce
 
Use the AfterUpdate event of the toggle button to turn the filter on or off:

This example assumes an unbound toggle button named "tgl":

Private Sub tgl_AfterUpdate()
If Me.tgl.Value Then
DoCmd.ApplyFilter "myFilter", myProdString
Else
Me.FilterOn = False
End If
End Sub

The code needs error handling, in case the record is dirty.
 
Back
Top