Filter Form by Command Button (I know it's simple)

andmunn

Registered User.
Local time
Today, 02:10
Joined
Mar 31, 2009
Messages
195
Hello!

I have searched for the answer, but can't seem to find it. I have a form (based on a query) which displays various fields:

1. MetricID
2. MetricName
3. MetricValue
4. IsImportant (True/False)

I want to create a command button in the header of this form which, when i click it wil lfilter only those metrics which are set to "True" for IsImportant.

I know this is simple, but i can't figure it out! Any advice appreciated.

Andrew.
 
Hi All,

I tried an "option group", with a "yes/no" label...and the following code:

Private Sub Frame139_AfterUpdate()
Select Case Frame139
Case 2
Me.Filter = "[IsQCReport] = -1"
Me.FilterOn = True
Case 3
Me.Filter = "[IsQCReport] = 0"
Me.FilterOn = True
Case 1
Me.FilterOn = False
End Select

End Sub

It does what i want - HOWEVER, it looses the filter i already have selected from a previous combo box. I.E.// i'm viewing only 1 business unit, and only want to see the "important / not important" for only that business unit. How can i not loose the existing filter, and simply "add" this options?

Andrew.
 
Instead of filtering the form, Query the form.
Change you query to query on the Option Group that you created.
Add code to the on change event of the option group

me.requery

If you need more help post back and I will elaberate
 
Hi ZigZag,

Thanks for the quick response. Which filter are you recommended i change? The first one (where i choos ethe business unit via. a combo box), or the second filter (the important / not important) filter?

Also, not sure what you mean by "Change you query to query on the Option Group that you created."

I'm very "newbie" at this - so any help is appreciated.

Andrew.
 
ZigZag,

Well, i played with it a bit, and in my query added the following critera:

"[Forms]![frmINTLScorecard]![WhatUnitYear]"

Basically, it specifies the business unit. Now the option group seems to work just fine (made no changes to option group), nor did i add teh "requery" text - is that what you meant?

Andrew.
 
Andrew

You say that your form is base on a query :-
In that query you have a field 'IsImportant (True/False)'

In the criteria section of that field you add
like [Forms]![frmINTLScorecard]![name of you option group]
It will look at what you have set in the option group and return only the results that match.

If you select 'no' in the option group it will not change anything until the form is requeried which is what the me.requery is for.

Let me know if that helps
 

Users who are viewing this thread

Back
Top Bottom