Group:  Microsoft Access » microsoft.public.access.formscoding
Thread: Apply initial filter from within form without requerying

Geek News

Apply initial filter from within form without requerying
brwn.fred[ at ]gmail.com 12/12/2008 1:37:13 PM
Hi,
I have a form whose data source is a very slow query.
I want to bring up the form with an initial filter without executing
my slow query twice. It appears that if I invoke the form with:
DoCmd.OpenForm "Form", WhereCondition:="Filter", it comes up with
Filter on and the data is queried only once.

I would prefer though to be able to apply the filter within the form
itself and then it can be invoked without the invoker knowing the
specifics of the Filter.

I tried in the form open procedure:
Me.Filter = "Filter": Me.FilterOn = true
This makes a requery happen. I tried applying the filter and then
setting Me.RecordSource. This resulted in the Filter not getting
applied although the query was only run once.

Is there a way to do what OpenForm does from within the code of a
form?

Thanks,
Fred Brown
RE: Apply initial filter from within form without requerying
Dale Fye 12/12/2008 4:44:01 PM
Don't know if this is exactly what you are looking for, but give it a try.

Set the Filter property to "Filter",a and the FilterOn property to False in
design view, so that although the filter is actually set, it does not
implement the filter?

Then, when your user clicks a "Filter" button, it would change the FilterOn
from False to true.

--
HTH
Dale

email address is invalid
Please reply to newsgroup only.



"brwn.fred[ at ]gmail.com" wrote:

[Quoted Text]
> Hi,
> I have a form whose data source is a very slow query.
> I want to bring up the form with an initial filter without executing
> my slow query twice. It appears that if I invoke the form with:
> DoCmd.OpenForm "Form", WhereCondition:="Filter", it comes up with
> Filter on and the data is queried only once.
>
> I would prefer though to be able to apply the filter within the form
> itself and then it can be invoked without the invoker knowing the
> specifics of the Filter.
>
> I tried in the form open procedure:
> Me.Filter = "Filter": Me.FilterOn = true
> This makes a requery happen. I tried applying the filter and then
> setting Me.RecordSource. This resulted in the Filter not getting
> applied although the query was only run once.
>
> Is there a way to do what OpenForm does from within the code of a
> form?
>
> Thanks,
> Fred Brown
>
Re: Apply initial filter from within form without requerying
brwn.fred[ at ]gmail.com 12/14/2008 1:57:32 PM
Thanks for the reply but I want the filter on initially and, again,
without causing a requery, I want the filter to be encapsulated in the
Form so that invocations of the form do not have to know about the
filter.

- Fred Brown




[Quoted Text]
> Don't know if this is exactly what you are looking for, but give it a try..
>
> Set the Filter property to "Filter",a and the FilterOn property to False in
> design view, so that although the filter is actually set, it does not
> implement the filter?
>
> Then, when your user clicks a "Filter" button, it would change the FilterOn
> from False to true.
>
> --
> HTH
> Dale
>
> email address is invalid
> Please reply to newsgroup only.
>
>
>
> "brwn.f...[ at ]gmail.com" wrote:
> > Hi,
> > I have a form whose data source is a very slow query.
> > I want to bring up the form with an initial filter without executing
> > my slow query twice.  It appears that if I invoke the form with:
> > DoCmd.OpenForm "Form", WhereCondition:="Filter", it comes up with
> > Filter on and the data is queried only once.
>
> > I would prefer though to be able to apply the filter within the form
> > itself and then it can be invoked without the invoker knowing the
> > specifics of the Filter.
>
> > I tried in the form open procedure:
> >      Me.Filter = "Filter": Me.FilterOn = true
> > This makes a requery happen.  I tried applying the filter and then
> > setting Me.RecordSource.  This resulted in the Filter not getting
> > applied although the query was only run once.
>
> > Is there a way to do what OpenForm does from within the code of a
> > form?
>
> > Thanks,
> > Fred Brown- Hide quoted text -
>
> - Show quoted text -

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net