D
DawnTreader
i have a main form with a subform. the main form and the subform are
unrelated. the subform is based on a query that lists a load of stuff and
does some calcs that use numbers on the main form with numbers from the
subform. this all works great.
i have some buttons that allow me to cause a filter to be applied to the
subform based on the code that i put in the buttons on click event. there are
6 buttons that turn on a specific filter and 6 other buttons that turn off
the filter. i know i probably should have used toggle buttons, but as i am
still learning i wanted to make it easy on myself. these buttons work fine,
except for one fine detail.
when i click the first filter button it does what it was meant to do, when i
click the second button it does what it was meant to do on top of the other
filter the first button did. this is exactly what i want. but when i turn off
one filter, it turns off all the others.
so here is the code i have for one set of buttons. i am imagining that i
might need to add something to each, or rewrite to make the previous filter
remain.
Code:
Private Sub btn10000off_Click()
On Error GoTo Err_btn10000off_Click
'this is necessary for the calculations on the subform
RunCommand acCmdSaveRecord
'this is the code to turn off the filter
Me.subfrmqryRepPartListCalcWFilter.Form.Filter = ""
Me.subfrmqryRepPartListCalcWFilter.Form.FilterOn = False
'this code changes the focus from the button just clicked so that it can
be disabled and turns on the button that is its opposite
Me.RepName.SetFocus
Me.btn10000off.Visible = False
Me.btn10000off.Enabled = False
Me.btn10000on.Visible = True
Me.btn10000on.Enabled = True
Exit_btn10000off_Click:
Exit Sub
Err_btn10000off_Click:
MsgBox Err.DESCRIPTION
Resume Exit_btn10000off_Click
End Sub
Private Sub btn10000on_Click()
On Error GoTo Err_btn10000on_Click
'this is necessary for the calculations on the subform
RunCommand acCmdSaveRecord
'this is the turning on of the filter
Me.subfrmqryRepPartListCalcWFilter.Form.Filter = "(([10000Rebuild] = -1))"
Me.subfrmqryRepPartListCalcWFilter.Form.FilterOn = True
'this code changes the focus from the button just clicked so that it can
be disabled and turns on the button that is its opposite
Me.RepName.SetFocus
Me.btn10000on.Visible = False
Me.btn10000on.Enabled = False
Me.btn10000off.Visible = True
Me.btn10000off.Enabled = True
Exit_btn10000on_Click:
Exit Sub
Err_btn10000on_Click:
MsgBox Err.DESCRIPTION
Resume Exit_btn10000on_Click
End Sub
thanks for any and all suggestions!
unrelated. the subform is based on a query that lists a load of stuff and
does some calcs that use numbers on the main form with numbers from the
subform. this all works great.
i have some buttons that allow me to cause a filter to be applied to the
subform based on the code that i put in the buttons on click event. there are
6 buttons that turn on a specific filter and 6 other buttons that turn off
the filter. i know i probably should have used toggle buttons, but as i am
still learning i wanted to make it easy on myself. these buttons work fine,
except for one fine detail.
when i click the first filter button it does what it was meant to do, when i
click the second button it does what it was meant to do on top of the other
filter the first button did. this is exactly what i want. but when i turn off
one filter, it turns off all the others.
so here is the code i have for one set of buttons. i am imagining that i
might need to add something to each, or rewrite to make the previous filter
remain.
Code:
Private Sub btn10000off_Click()
On Error GoTo Err_btn10000off_Click
'this is necessary for the calculations on the subform
RunCommand acCmdSaveRecord
'this is the code to turn off the filter
Me.subfrmqryRepPartListCalcWFilter.Form.Filter = ""
Me.subfrmqryRepPartListCalcWFilter.Form.FilterOn = False
'this code changes the focus from the button just clicked so that it can
be disabled and turns on the button that is its opposite
Me.RepName.SetFocus
Me.btn10000off.Visible = False
Me.btn10000off.Enabled = False
Me.btn10000on.Visible = True
Me.btn10000on.Enabled = True
Exit_btn10000off_Click:
Exit Sub
Err_btn10000off_Click:
MsgBox Err.DESCRIPTION
Resume Exit_btn10000off_Click
End Sub
Private Sub btn10000on_Click()
On Error GoTo Err_btn10000on_Click
'this is necessary for the calculations on the subform
RunCommand acCmdSaveRecord
'this is the turning on of the filter
Me.subfrmqryRepPartListCalcWFilter.Form.Filter = "(([10000Rebuild] = -1))"
Me.subfrmqryRepPartListCalcWFilter.Form.FilterOn = True
'this code changes the focus from the button just clicked so that it can
be disabled and turns on the button that is its opposite
Me.RepName.SetFocus
Me.btn10000on.Visible = False
Me.btn10000on.Enabled = False
Me.btn10000off.Visible = True
Me.btn10000off.Enabled = True
Exit_btn10000on_Click:
Exit Sub
Err_btn10000on_Click:
MsgBox Err.DESCRIPTION
Resume Exit_btn10000on_Click
End Sub
thanks for any and all suggestions!