removing subform filters (1 Viewer)

adam_fleck

Registered User.
Local time
Today, 17:52
Joined
Apr 30, 2004
Messages
85
When a filter is removed from a subform, any filter that had been applied to the main form is removed too. This a nuisance. I've got a work around but it's ugly.

Here's what happens. Right clicking the subform calls up a custom menu that has a custom Remove Filter option. This in turn calls a function that runs the code:

forms("main_form")("sub_form").form.filter = ""

For no reason that makes sense to me, this also removes any filter that has been applied to main_form. My work around is to trap the main_form filter and the current main_form record, reapply the main_form filter, and navigate back to the record that was current.

This sort of works, but I'm wondering if anyone knows of a way of turning off what seems to me to be a really silly bit of behaviour.
 

Tim K.

Registered User.
Local time
Today, 16:52
Joined
Aug 1, 2002
Messages
242
You have to put this line too.

forms("main_form")("sub_form").form.filteron = FALSE
 

adam_fleck

Registered User.
Local time
Today, 17:52
Joined
Apr 30, 2004
Messages
85
Still no luck

I've tried that thanks, but it still don't work.

It seems that any time you take a filter off a subform, the filter on the main form is removed too. Oh well.
 

adam_fleck

Registered User.
Local time
Today, 17:52
Joined
Apr 30, 2004
Messages
85
Got it at last

Just in case anyone else runs up against this. To remove a subform filter without removing any filter that has been applied to the main form, reset the Recordsource property of the subform to it's original value.

In the code frag below, str_SF_SQL is the SQL statement that was originally used to set the subform's recordsource.

Forms("main_form").sub_form.Form.RecordSource = str_SF_SQL

Strange, but it works.
 
Last edited:

Users who are viewing this thread

Top Bottom