Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Toggle Buttons Lose Focus and Filter 1

Status
Not open for further replies.

pbundrant

Technical User
Feb 24, 2002
51
US
Hi,

I have an option group with four toggle buttons on my main form. I'm using them to filter the subform records. I'm sure there is a way to condense the code but I think it works fine. However when I click into the subform to scroll the records the LostFocus clears the applied filter. Any suggestions? I need the last toggle button pushed to keep the focus even when clicking outside of the option group.

tglAllRecords - no code, default toggle button


Private Sub tglCompleted_GotFocus()

Dim subfrm As Access.Form
Dim strFilter As String
Set subfrm = Me.frmLianzi_MDR_Form_Updates.Form
subfrm.Filter = "Progress = 100"
subfrm.FilterOn = True

End Sub

Private Sub tglCompleted_LostFocus()

Dim subfrm As Access.Form
Dim strFilter As String
Set subfrm = Me.frmLianzi_MDR_Form_Updates.Form
subfrm.Filter = "Progress = 100"
subfrm.FilterOn = False

End Sub

Private Sub tglInProcess_GotFocus()

Dim subfrm As Access.Form
Dim strFilter As String
Set subfrm = Me.frmLianzi_MDR_Form_Updates.Form
subfrm.Filter = "Progress < 100 OR Progress IS NULL"
subfrm.FilterOn = True

End Sub

Private Sub tglInProcess_LostFocus()

Dim subfrm As Access.Form
Dim strFilter As String
Set subfrm = Me.frmLianzi_MDR_Form_Updates.Form
subfrm.Filter = "Progress < 100 OR Progress IS NULL"
subfrm.FilterOn = False

End Sub


Private Sub tglNotStarted_GotFocus()

Dim subfrm As Access.Form
Dim strFilter As String
Set subfrm = Me.frmLianzi_MDR_Form_Updates.Form
subfrm.Filter = "[A-START] IS NULL"
subfrm.FilterOn = True

End Sub

Private Sub tglNotStarted_LostFocus()

Dim subfrm As Access.Form
Dim strFilter As String
Set subfrm = Me.frmLianzi_MDR_Form_Updates.Form
subfrm.Filter = "[A-START] IS NULL"
subfrm.FilterOn = False

End Sub

TYIA,
Patty
[ponytails]
 
Don't use any LostFocus event procedure:
Code:
Private Sub tglAllRecords_GotFocus()
Me!frmLianzi_MDR_Form_Updates.Form.FilterOn = False
End Sub

Private Sub tglCompleted_GotFocus()
With Me!frmLianzi_MDR_Form_Updates.Form
    .Filter = "Progress = 100"
    .FilterOn = True
End With
End Sub

Private Sub tglInProcess_GotFocus()
With Me!frmLianzi_MDR_Form_Updates.Form
    .Filter = "Progress < 100 OR Progress IS NULL"
    .FilterOn = True
End With
End Sub

Private Sub tglNotStarted_GotFocus()
With Me!frmLianzi_MDR_Form_Updates.Form
    .Filter = "[A-START] IS NULL"
    .FilterOn = True
End With
End Sub

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Actually the tglAllRecords is not clearing the filter after all the others have been pressed and worked like they should.
 
Perhaps this instead ?
Code:
Private Sub tglAllRecords_GotFocus()
With Me!frmLianzi_MDR_Form_Updates.Form
    .FilterOn = False
    .Filter = ""
End With
End Sub

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
That was it!
Thank you again, have a great weekend!
Patty
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top