Clearing filters in subform (1 Viewer)

jonathanchye

Registered User.
Local time
Today, 12:36
Joined
Mar 8, 2011
Messages
448
I'm slightly confused at what is happening so hopefully something could offer some advice...

I have a subform in datasheet view and a button on the main form which is used to clear all filters in the subform.

The button's OnClick event calls a procedure on the subform. The procedure in the subform has the following code :

Code:
Me.filter = ""
Me.filterOn = false
Docmd.Save acform, subformName
Debug.Print "Filter : " & Me.filter
Me.requery

I also have debug print outs which shows the current filter on the forms OnLoad and OnClose events.

Everything works fine but somehow when I reopen the main form (with subform) the filter gets reset to the previous one.

I can change filters and that saves ok but if I clear filter it always returns to the previous ones when I reopen the form containing the subform...

What am I doing wrong?

For reference the filter string in subform looks like "(qrySubformQuerySource.Fieldname)="xx""
 

jonathanchye

Registered User.
Local time
Today, 12:36
Joined
Mar 8, 2011
Messages
448
Right... this is getting weird. I've manually cleared the filter in the subform (Design View > Property Sheet > Data tab > Filter and saved the subform. Now it won't remember the last filters!
 

Isskint

Slowly Developing
Local time
Today, 12:36
Joined
Apr 25, 2012
Messages
1,302
Not sure if this is as easy as it appears, but just set FilterOn = False in the FormOpen event for the main form, that way no filters would be active after opening the form? Dont forget the main form sub form syntax>> MainForm!SubFormHolderName.Form
 

jonathanchye

Registered User.
Local time
Today, 12:36
Joined
Mar 8, 2011
Messages
448
Hi, thanks for the reply. I've thought about doing that but in some cases I still want users to "remember" the filters. Basically I want the filter to be saved everytime it's changed.

I might have missed something here as right now I can't even save the filters anymore o.0
 

jonathanchye

Registered User.
Local time
Today, 12:36
Joined
Mar 8, 2011
Messages
448
Anyone using MS Access 2010 managed to get filters saved in Datasheet view at all? Basically all I want to do is for the subform to remember the user's last saved filters.

I have inserted debug.print statements during the forms load and close events. From observation the filter gets cleared the next time the subform is reopened. I have checked my code and there's nothing clearing the filters. I have the subform's apply filter on load property set to yes but that doesn't seem to help.

It's just not saving the last filter to the form somehow... I have force a Docmd.Save in the subform's On Apply filter event but that doesn't help...

Edit: Urgh...this is frustrating. Have another similiar-ish form and filters seem to save on that one. The only difference in this is that the subform resides in a tab control...
 
Last edited:

jonathanchye

Registered User.
Local time
Today, 12:36
Joined
Mar 8, 2011
Messages
448
Right, the only difference between the form that's working and not is that in the form that's not working I have the subforms in a tab control. Will tab control be the issue here?
 

Users who are viewing this thread

Top Bottom