From: Dennis on
In Access2003, I have a subform that I set a filter for on initial lookup. It
works fine. Then, I want to "re-filter" the data (for example, to limit the
records displayed to those matching a certain Job Number for a given Tech),
but the subform doesn't seem to requery.

I've tried the following to no effect:

Me.HoursDetail.Form.Filter = FilterString

where HoursDetail is the name of the subform control on the parent form, and
FilterString is the text of the filter. If I close and reopen the subform as
stand-alone, the new filter gets applied properly, but of course that defeats
the purpose of having a subform.

I have also tried to use:

Me.HoursDetail.Requery

afterward, but also to no effect

Any ideas would be most helpful.

TIA!
From: Marshall Barton on
Dennis wrote:

>In Access2003, I have a subform that I set a filter for on initial lookup. It
>works fine. Then, I want to "re-filter" the data (for example, to limit the
>records displayed to those matching a certain Job Number for a given Tech),
>but the subform doesn't seem to requery.
>
>I've tried the following to no effect:
>
>Me.HoursDetail.Form.Filter = FilterString
>
>where HoursDetail is the name of the subform control on the parent form, and
>FilterString is the text of the filter. If I close and reopen the subform as
>stand-alone, the new filter gets applied properly, but of course that defeats
>the purpose of having a subform.
>
>I have also tried to use:
>
>Me.HoursDetail.Requery
>
>afterward, but also to no effect


Did you forget to use:
Me.HoursDetail.Form.FilterOn = True

--
Marsh
MVP [MS Access]
From: Daryl S on
Dennis -

Try these (note the .Form in the statements):

Me.HoursDetail.Form.FilterOn
Me.HoursDetail.Form.Requery

--
Daryl S


"Dennis" wrote:

> In Access2003, I have a subform that I set a filter for on initial lookup. It
> works fine. Then, I want to "re-filter" the data (for example, to limit the
> records displayed to those matching a certain Job Number for a given Tech),
> but the subform doesn't seem to requery.
>
> I've tried the following to no effect:
>
> Me.HoursDetail.Form.Filter = FilterString
>
> where HoursDetail is the name of the subform control on the parent form, and
> FilterString is the text of the filter. If I close and reopen the subform as
> stand-alone, the new filter gets applied properly, but of course that defeats
> the purpose of having a subform.
>
> I have also tried to use:
>
> Me.HoursDetail.Requery
>
> afterward, but also to no effect
>
> Any ideas would be most helpful.
>
> TIA!
From: Dennis on
Daryl, I did the filterOn = True. But do you have to have that set to true
BEFORE changing the filter text?

marshall, the reQuery was ineffective. I've done this successfully in times
past, so I KNOW it's possible. But this thread was started because I had no
freakin' clue as to why it wouldn't work. So I guess I'm still kind-of at a
loss as to what's not working properly. Any other ideas? (Oh, I just
remembered - the subform is not actually tied to the parent form. It's a
fully independent query that drives it, and I set an initial filter when I
open the parent.)

Thanks guys!

Dennis



"Marshall Barton" wrote:

> Dennis wrote:
>
> >In Access2003, I have a subform that I set a filter for on initial lookup. It
> >works fine. Then, I want to "re-filter" the data (for example, to limit the
> >records displayed to those matching a certain Job Number for a given Tech),
> >but the subform doesn't seem to requery.
> >
> >I've tried the following to no effect:
> >
> >Me.HoursDetail.Form.Filter = FilterString
> >
> >where HoursDetail is the name of the subform control on the parent form, and
> >FilterString is the text of the filter. If I close and reopen the subform as
> >stand-alone, the new filter gets applied properly, but of course that defeats
> >the purpose of having a subform.
> >
> >I have also tried to use:
> >
> >Me.HoursDetail.Requery
> >
> >afterward, but also to no effect
>
>
> Did you forget to use:
> Me.HoursDetail.Form.FilterOn = True
>
> --
> Marsh
> MVP [MS Access]
> .
>
From: Daryl S on
Dennis -

No, I should have indicated these were two different things to try. I would
make sure the filter was turned on after providing the filter criteria. I
assume the filter criteria you are writing is good for the recordsource of
the subform, since that data is not related to the parent form. You
shouldn't need to requery if you are just applying a filter that is
consistent with the records in the subform.

When you run your code, does the filter not work? What happens if you
toggle the Apply Filter button when the focus is in the subform - can you see
the filter being applied and removed? If so, the syntax of the filter string
is probably fine, and you may want to try the ApplyFilter of the DoCmd...

--
Daryl S


"Dennis" wrote:

> Daryl, I did the filterOn = True. But do you have to have that set to true
> BEFORE changing the filter text?
>
> marshall, the reQuery was ineffective. I've done this successfully in times
> past, so I KNOW it's possible. But this thread was started because I had no
> freakin' clue as to why it wouldn't work. So I guess I'm still kind-of at a
> loss as to what's not working properly. Any other ideas? (Oh, I just
> remembered - the subform is not actually tied to the parent form. It's a
> fully independent query that drives it, and I set an initial filter when I
> open the parent.)
>
> Thanks guys!
>
> Dennis
>
>
>
> "Marshall Barton" wrote:
>
> > Dennis wrote:
> >
> > >In Access2003, I have a subform that I set a filter for on initial lookup. It
> > >works fine. Then, I want to "re-filter" the data (for example, to limit the
> > >records displayed to those matching a certain Job Number for a given Tech),
> > >but the subform doesn't seem to requery.
> > >
> > >I've tried the following to no effect:
> > >
> > >Me.HoursDetail.Form.Filter = FilterString
> > >
> > >where HoursDetail is the name of the subform control on the parent form, and
> > >FilterString is the text of the filter. If I close and reopen the subform as
> > >stand-alone, the new filter gets applied properly, but of course that defeats
> > >the purpose of having a subform.
> > >
> > >I have also tried to use:
> > >
> > >Me.HoursDetail.Requery
> > >
> > >afterward, but also to no effect
> >
> >
> > Did you forget to use:
> > Me.HoursDetail.Form.FilterOn = True
> >
> > --
> > Marsh
> > MVP [MS Access]
> > .
> >