AbacusInfoTech
asked on
Unable to remove filter from multiple subforms.
Probably a really easy and fundamental answer to this one. I have a button that is meant to clear a filter on two subforms. I can clear the filter from one form, or the other form, but not both.
Whichever code I use, only the first one in the list is cleared, the second remains filtered.
Me.cboClientFilter.Value = ""
Forms!frmMainJobs!frmJobsC omplete.Fo rm.FilterO n = False
Forms!frmMainJobs!frmJobsI nProgress. Form.Filte rOn = False
OR
Me.cboClientFilter.Value = ""
Forms!frmMainJobs!frmJobsI nProgress. Form.Filte rOn = False
Forms!frmMainJobs!frmJobsC omplete.Fo rm.FilterO n = False
What am I doing wrong?
Whichever code I use, only the first one in the list is cleared, the second remains filtered.
Me.cboClientFilter.Value = ""
Forms!frmMainJobs!frmJobsC
Forms!frmMainJobs!frmJobsI
OR
Me.cboClientFilter.Value = ""
Forms!frmMainJobs!frmJobsI
Forms!frmMainJobs!frmJobsC
What am I doing wrong?
ASKER
Thanks, but same problem. It's really weird.
I swapped your code around to:
Me.cboClientFilter.Value = ""
Forms!frmMainJobs!frmJobsI nProgress. Form.Filte r = ""
Forms!frmMainJobs!frmJobsI nProgress. Form.Filte rOn = False
Forms!frmMainJobs!frmJobsC omplete.Fo rm.Filter = ""
Forms!frmMainJobs!frmJobsC omplete.Fo rm.FilterO n = False
And again only the first subform clears.
As a test I tried using two separate buttons so button A clears form A and button B clears form B but I get the same behaviour. The first one I press will work but the second will not. It's as if Access will not allow me to clear the filter more than once in a given "session". Session is the wrong word I'm sure but you get my drift.
If it helps, I have this code in the afterupdate on my combo, this is the one that actually filters both subforms in one go (successfully)
Me.frmJobsInProgress.Form. Filter = "name='" & Me.cboClientFilter.Value & "'"
Me.frmJobsInProgress.Form. FilterOn = True
Me.frmJobsComplete.Form.Fi lter = "name='" & Me.cboClientFilter.Value & "'"
Me.frmJobsComplete.Form.Fi lterOn = True
I swapped your code around to:
Me.cboClientFilter.Value = ""
Forms!frmMainJobs!frmJobsI
Forms!frmMainJobs!frmJobsI
Forms!frmMainJobs!frmJobsC
Forms!frmMainJobs!frmJobsC
And again only the first subform clears.
As a test I tried using two separate buttons so button A clears form A and button B clears form B but I get the same behaviour. The first one I press will work but the second will not. It's as if Access will not allow me to clear the filter more than once in a given "session". Session is the wrong word I'm sure but you get my drift.
If it helps, I have this code in the afterupdate on my combo, this is the one that actually filters both subforms in one go (successfully)
Me.frmJobsInProgress.Form.
Me.frmJobsInProgress.Form.
Me.frmJobsComplete.Form.Fi
Me.frmJobsComplete.Form.Fi
"It's as if Access will not allow me to clear the filter more than once in a given "session". "
Well, that should not be the case. I've had some subtle issues when clearing filters.
But I'm confused ... setting the filters you have:
Me.frmJobsInProgress.Form. Filter
but you are not referencing frmMainJobs ... as you are when clearing ... ?
mx
Well, that should not be the case. I've had some subtle issues when clearing filters.
But I'm confused ... setting the filters you have:
Me.frmJobsInProgress.Form.
but you are not referencing frmMainJobs ... as you are when clearing ... ?
mx
ASKER
I think I understand what you are asking,
frmJobsInProgress and frmJobsComplete are the names of the subforms I am filtering on my main from frmMainJobs...
Am I doing something wrong here...?
frmJobsInProgress and frmJobsComplete are the names of the subforms I am filtering on my main from frmMainJobs...
Am I doing something wrong here...?
Well ... you say setting the filters works ... and you have this systax:
Me.frmJobsInProgress.Form. Filter = "name='" & Me.cboClientFilter.Value & "'"
Me.frmJobsInProgress.Form. FilterOn = True
But ... you don't have the Main form name like you do here where you are trying to clear:
Forms!frmMainJobs!frmJobsI nProgress. Form.Filte r = ""
Forms!frmMainJobs!frmJobsI nProgress. Form.Filte rOn = False
^^^^^^^^^^^^^
So actually, I'm not seeing how the setting of the filters is working ...?
Also confirming ... you have two different subforms on one main form, correct ?
And ... the combo is on the Main form ??
mx
Me.frmJobsInProgress.Form.
Me.frmJobsInProgress.Form.
But ... you don't have the Main form name like you do here where you are trying to clear:
Forms!frmMainJobs!frmJobsI
Forms!frmMainJobs!frmJobsI
^^^^^^^^^^^^^
So actually, I'm not seeing how the setting of the filters is working ...?
Also confirming ... you have two different subforms on one main form, correct ?
And ... the combo is on the Main form ??
mx
ASKER
I see what you are saying, and for the sake of consistency have changed the code on my combo to:
Private Sub cboClientFilter_AfterUpdat e()
Forms!frmMainJobs!frmJobsI nProgress. Form.Filte r = "name='" & Me.cboClientFilter.Value & "'"
Forms!frmMainJobs!frmJobsI nProgress. Form.Filte rOn = True
Forms!frmMainJobs!frmJobsC omplete.Fo rm.Filter = "name='" & Me.cboClientFilter.Value & "'"
Forms!frmMainJobs!frmJobsC omplete.Fo rm.FilterO n = True
End Sub
The two subforms still filter 'as expected'.
The button code remains:
Me.cboClientFilter.Value = ""
Forms!frmMainJobs!frmJobsI nProgress. Form.Filte r = ""
Forms!frmMainJobs!frmJobsI nProgress. Form.Filte rOn = False
Forms!frmMainJobs!frmJobsC omplete.Fo rm.Filter = ""
Forms!frmMainJobs!frmJobsC omplete.Fo rm.FilterO n = False
(OR)
Me.cboClientFilter.Value = ""
Forms!frmMainJobs!frmJobsC omplete.Fo rm.Filter = ""
Forms!frmMainJobs!frmJobsC omplete.Fo rm.FilterO n = False
Forms!frmMainJobs!frmJobsI nProgress. Form.Filte r = ""
Forms!frmMainJobs!frmJobsI nProgress. Form.Filte rOn = False
And still the first subform in the code gets cleared.
The two subforms are indeeed on the one main form. The combo is on the main form.
I will dummy the data and post the database up here...
Private Sub cboClientFilter_AfterUpdat
Forms!frmMainJobs!frmJobsI
Forms!frmMainJobs!frmJobsI
Forms!frmMainJobs!frmJobsC
Forms!frmMainJobs!frmJobsC
End Sub
The two subforms still filter 'as expected'.
The button code remains:
Me.cboClientFilter.Value = ""
Forms!frmMainJobs!frmJobsI
Forms!frmMainJobs!frmJobsI
Forms!frmMainJobs!frmJobsC
Forms!frmMainJobs!frmJobsC
(OR)
Me.cboClientFilter.Value = ""
Forms!frmMainJobs!frmJobsC
Forms!frmMainJobs!frmJobsC
Forms!frmMainJobs!frmJobsI
Forms!frmMainJobs!frmJobsI
And still the first subform in the code gets cleared.
The two subforms are indeeed on the one main form. The combo is on the main form.
I will dummy the data and post the database up here...
Can you:
1) Compact & Repair (*** to shrink the size),
2) Zip up the MDB (*** to further shrink the size)
3) Attach the file for upload here (using the 'Attach File function below) ... removing any sensitive data of course.
4**** And please give a clear explanation of exactly how to reproduce the problem or what you are trying to do.
NOTE: If you have an A2007 ACCDB, please convert to A2003 MDB.
mx
1) Compact & Repair (*** to shrink the size),
2) Zip up the MDB (*** to further shrink the size)
3) Attach the file for upload here (using the 'Attach File function below) ... removing any sensitive data of course.
4**** And please give a clear explanation of exactly how to reproduce the problem or what you are trying to do.
NOTE: If you have an A2007 ACCDB, please convert to A2003 MDB.
mx
ASKER
Okay, this is the database. Hook up the linked tables, open the front end, go to 'Jobs'.
On this screen you'll see *ALL* jobs for all clients both in progress and complete.
You can filter for a given client and both subforms will update.
If you choose Willy Wonka you'll get filtered data in both subforms.
When you press 'clear filter' only one subform will revert to all data
You can swap the code around on the button as described earlier but then only the other subform will revert to unfiltered data.
eedb.zip
On this screen you'll see *ALL* jobs for all clients both in progress and complete.
You can filter for a given client and both subforms will update.
If you choose Willy Wonka you'll get filtered data in both subforms.
When you press 'clear filter' only one subform will revert to all data
You can swap the code around on the button as described earlier but then only the other subform will revert to unfiltered data.
eedb.zip
standby
weird I must say ...
mx
mx
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks, I'll take a look now.
ASKER
Thank you very much for your help, works just fine!
You are welcome. Thank you for using Experts Exchange. Spread the word :-)
mx
mx
Would have made it easier if you had posted the answer(I have included your code below). I have a similar problem and this seems to be a known bug in Access and the solution is to 'change the recordsource' but I wasn't sure how to do it. Reading your code has shown me. Thanks
Private Sub btnClearClientFilter_Click()
Dim x As String
With Me
.cboClientFilter.Value = ""
x = .fsubJobsInProgress.Form.RecordSource
.fsubJobsInProgress.Form.Filter = ""
.fsubJobsInProgress.Form.FilterOn = False
.fsubJobsInProgress.Form.RecordSource = x
x = .fsubJobsComplete.Form.RecordSource
.fsubJobsComplete.Form.Filter = ""
.fsubJobsComplete.Form.FilterOn = False
.fsubJobsComplete.Form.RecordSource = x
End With
End Sub
Well, I suppose, but at the time, the OP was the only one needing the fix. You can always download the db and check it out ...
mx
mx
Me.cboClientFilter.Value = ""
Forms!frmMainJobs!frmJobsC
Forms!frmMainJobs!frmJobsC
Forms!frmMainJobs!frmJobsI
Forms!frmMainJobs!frmJobsI
mx