Filter with a checkbox (1 Viewer)

wrweaver

Registered User.
Local time
Today, 00:21
Joined
Feb 26, 2013
Messages
75
I'm trying to filter a continuous form with a filter using a checkbox where when you check the checkbox it applies the filter and when you uncheck it, the filter is taken off and all records are shown. But I can't get the check = false to take the filter off.

Private Sub Check19_AfterUpdate()
If Check19 = True Then

DoCmd.ApplyFilter , "[ContractActive] = True"
If Check19 = False Then
Exit Sub
End If
End If
End Sub
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 00:21
Joined
Aug 30, 2003
Messages
36,124
Does it become more obvious with the code indented?

Code:
  If Check19 = True Then

    DoCmd.ApplyFilter , "[ContractActive] = True"
    If Check19 = False Then
      Exit Sub
    End If
  End If

You want an Else clause in the first If, not another If.
 

wrweaver

Registered User.
Local time
Today, 00:21
Joined
Feb 26, 2013
Messages
75
Ohhh. Yeah, but that doesn't undo the filter. Even unchecked, the filter is still on.
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 00:21
Joined
Aug 30, 2003
Messages
36,124
No, you have to undo it in the Else clause. I haven't used that method to filter, but try

Me.FilterOn = False
 

wrweaver

Registered User.
Local time
Today, 00:21
Joined
Feb 26, 2013
Messages
75
Annnnnnd success. Again, pbaldy saves the day. Thank you!
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 00:21
Joined
Aug 30, 2003
Messages
36,124
Happy to help!
 

Users who are viewing this thread

Top Bottom