How to change .Filter or .FilterOn

E

ericb

On a form is a number of command buttons and a subform.

I would like to use the 'on click' event of a button to change the filter of
the subform and to get different lists of people.

All my filters work and are stored in respective queries.

How do I write an event procedure on the click event to change the Filter
and update the subform ?

Thank you for the help.
 
S

Steve

The code I gave you is for the button being on the subform, if the button is
on the main form, try:

Me!NameOfSubformControl.Form.FilterOn = True
Me!NameOfSubformControl.Form.Requery

To get the Name Of Subform Control, open the main form in design view.
Select the control that holds the subform. Open properties and go to the
Other tab. The Name Of Subform Control is what you see in the Name property.

Steve
(e-mail address removed)
 
S

Steve

I'm not sure what you mean by a new list of people. Your filter is deigned
to give you a list of people that meet certain criteria.

Steve
 
E

ericb

The buttons are next to the subform on the main form. The data on the subform
is in datasheet view.

I have no code to show you because I know very little (or closer to 0) about
VBasic.

But what I want is to have 4 buttons, to each button I have a filter
associated to it. When I click a button it changes the filter parameter in
the subform's propertie sheet under the Data Tab.

The 4 filters are set up in 4 different queries that work fine.

Once the filter is changed, it will update the data and repopulate my list.
That way I can have the list of people that came to the office in the last
30, 60, 90, 120 days.

I do not simply want to turn off or on the filter, I want a new one.

What code do I need for that ?

While we're at it, how do I change to color of the select button ?

Thank you very much.
 
S

Steve

Hi Eric,

You can show a list of people that came to the office in the last 30, 60,
90, 120 days in a much simpler way!
1. Create an unbound option group named NumOfLastDays of four options on
your main form.
2. Name the options 30 Days, 60 Days, 90 Days and 120 Days. The options
will have the values 1, 2, 3 and 4.
3. You only need one query that contains the date field of when a person
came to the office.
4. Put the following expression in the criteria of that date field:
Between DateAdd("d",-(Forms!NameOfYourForm!NumOfLastDays *
30),Date()) And Date
5. Put the following code in the AfterUpdate event of the option group,
NumOfLastDays:
Me!NameOfSubformControl.Form.Requery

Steve
(e-mail address removed)
 

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