Apply initial filter from within form without requerying

B

brwn.fred

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
 
D

Dale Fye

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.
 
B

brwn.fred

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top