Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / March 2007

Tip: Looking for answers? Try searching our database.

Resetting subform filters

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rémi - 13 Mar 2007 23:22 GMT
Hi all.
I have a form with two unbound subforms.  The main form has a combobox
whose selection I use to filter *both* subforms.  Code called on after
update:

Private Sub cmbMyCombo_AfterUpdate()
    If IsNull(cmbMyCombo) then _
         cmbMyCombo=-1

    if cmbMyCombo=-1 then
         me.frmSubForm1.Form.FilterOn = False
         me.frmSubForm2.Form.FilterOn = False
    else
         me.frmSubForm1.Form.Filter="myComboId=" & cmbMyCombo
         me.frmSubForm1.Form.FilterOn = true
         me.frmSubForm2.Form.Filter="myComboId=" & cmbMyCombo
         me.frmSubForm2.Form.FilterOn = true
    end if
End Sub

When cmbMyCombo has a value of -1, I want to display everything.  I've
found, though, that resetting the subform's filter only works for the
first subform - the second doesn't get reset. I've also tried
Filter="", FilterOn=true, but I get the same thing.

The only thing that's worked for me so far is this:

if cmbMyCombo=-1 then
    me.frmSubform1.Form.FilterOn = false
    me.frmSubform2.Form.Filter= "myComboId<>-1"
    me.frmSubform2.Form.FilterOn=true
else
...

Has anyone seen this?  I'm using Access XP SP3.

Regards,
Remi.
Damian S - 14 Mar 2007 00:19 GMT
Hi Remi,

Are you requerying your subforms after clearing the filter?  And what is the
recordsource for your subforms?  Is the default recordsource filtering the
records unwittingly?

Damian.

> Hi all.
> I have a form with two unbound subforms.  The main form has a combobox
[quoted text clipped - 34 lines]
> Regards,
> Remi.
Rémi - 14 Mar 2007 01:06 GMT
Not requerying - it isn't necessary when I change the filter, I
wouldn't expect it to be necessary here...  (Am I wrong?)  Another
thing to note is that the *first* subform's filter is properly reset.
If I reverse the order I set FilterOn=false to, frmSubForm2 will have
its' data properly reset while frmSubForm1 does not.

The recordsource on both subforms is set to a table - not a query or
SQL.  No accidental filtering :-(

Remi.

On Mar 13, 4:19 pm, Damian S <Dami...@discussions.microsoft.com>
wrote:
> Hi Remi,
>
[quoted text clipped - 42 lines]
> > Regards,
> > Remi.
Damian S - 14 Mar 2007 02:26 GMT
Hi again Remi,

No, a requery is generally not required when applying/removing filters, but
since your filter isn't working, I was wondering if you could force a requery
to see if it resolved your issue.

Disregard that, as I have tested here and reproduced your problem.  Requery
doesn't fix it on its own, but if you reset the subforms recordsource and
then requery it your problem will be resolved... like this:

   Me.SUBFORM1.Form.Filter = ""
   Me.SUBFORM1.Form.FilterOn = False
   Me.SUBFORM1.Form.RecordSource = "TABLE1"
   Me.SUBFORM1.Requery
   
   Me.SUBFORM2.Form.Filter = ""
   Me.SUBFORM2.Form.FilterOn = False
   Me.SUBFORM2.Form.RecordSource = "TABLE2"
   Me.SUBFORM2.Requery

Must be an undocumented feature of Access...  I tested on A2003.

Damian.

> Not requerying - it isn't necessary when I change the filter, I
> wouldn't expect it to be necessary here...  (Am I wrong?)  Another
[quoted text clipped - 55 lines]
> > > Regards,
> > > Remi.
Rémi - 14 Mar 2007 17:54 GMT
Thanks.
I suppose its' that, or continuing to assign "invalid" criteria to my
filter - criteria that will return all records.

Regards,
Remi.

On Mar 13, 5:26 pm, Damian S <Dami...@discussions.microsoft.com>
wrote:
> Hi again Remi,
>
[quoted text clipped - 79 lines]
> > > > Regards,
> > > > Remi.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.