Filter using group option or combo box

R

Reader1

Hello

I would like to add an option on a form that lets the user filter the
records that are displayed.

At the moment I am using three different forms, one for each filter sort and
another to show all unfiltered records.

For example .......

I have a table called tblData with fields, Phase, Unit, Descriptor

The associated form is called frmData which displays all the records in each
three fields from the table.

I would like a way of displaying only those records that match the criteria
specified on the filter.

I only want to filter on the field called 'Phase' which has entries of
either 'A' , 'B' or 'C'

Maybe an option group or a combo box ?

So on the form if you click the option that says 'A' you would only see
records on the form that have 'A' in the Phase field

The same for 'B' and 'C' and another to show all records.

I'm new at this so make it simple please.

Thank you
 
G

Guest

Not sure how simple this will be, but don't get scared off by the length of
this post. One solution is to put an Option Group from the toolbox. Make
sure the wizard is turned on so that it will do most of the work for you.

The first screen is where you put your labels (e.g. All, A, B, C) and can be
anything since we will be using the associated values on the third screen of
the wizard. The second screen allows you to select a default value. I would
suggest using All or tell it you don't want a default. The third screen is
where the values are entered and these need to be numbers. Assuming you
entered the labels on the first screen in the All, A, B, C order, then leave
the values as 1 - 4 so that it looks like this:

Label - Value
All - 1
A - 2
B - 3
C - 4

On the fourth screen of the wizard use the first option to save the value
for later use. The fifth screen lets you choose the look of the Option Group
and is totally up to you and the last screen lets you label the control
(something like "Filter").

After you click finish, you need to bring up the properties of the newly
created option group. Go to the AfterUpdate event and click the build button
(...) to the right. Select Code Builder and then OK. Paste the following
code, but you will need to change the "Frame3" to whatever the number is for
your option group/frame. Just look right above the 'Code Start where it says
"Private Sub FrameXX_AfterUpdate()" - - XX will be your frame number.

'Code Start
Select Case Me.Frame3.Value '<-- Change the "3" to your frame number
Case 1
Me.FilterOn = False
Case 2
Me.Filter = "Phase ='A'"
Me.FilterOn = True
Case 3
Me.Filter = "Phase ='B'"
Me.FilterOn = True
Case 4
Me.Filter = "Phase ='C'"
Me.FilterOn = True
End Select
'Code End

Jeff
 
R

Reader1

Jeff you are a STAR !!!

It worked first time.

Thank you so much for your help and for taking the time to reply.

:)

<Very Big Grin>
 

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