Help with Form Filter Please

  • Thread starter Thread starter TD
  • Start date Start date
T

TD

I have a form that is based on one large table. This table has a field with
"Group Types" as one of the fields. When I open the form I see ALL records
in the database. What I would like to do is put some buttons on the form
that when I push Button A, it filters the database and only shows records
that have a Group Type = A. If I push Button B, it filters the database and
only shows records that have a Group Type = B., etc....

Can anyone please guide me on how to accomplish this?

Many thanks,
TD
 
I have a form that is based on one large table. This table has a field with
"Group Types" as one of the fields. When I open the form I see ALL records
in the database. What I would like to do is put some buttons on the form
that when I push Button A, it filters the database and only shows records
that have a Group Type = A. If I push Button B, it filters the database and
only shows records that have a Group Type = B., etc....

Can anyone please guide me on how to accomplish this?

Many thanks,
TD

Many Command buttons are a bit much for something like this.
Let's try one combo box.

I'm a bit confused, however. Are the letters A, B, C, etc. literal
names of departments? Or are they representing the first letters of
departments? Or are your GroupTypes really full names, such as
Accounting, Design, etc.

I'll assume it's the literal letter, A, B, C, etc.

Add a combo box to the form header.
Set it's RowSource type to Table/Query
Set it's Row Source to something like this (all on one line):
SELECT DISTINCT [GroupTypes] FROM YourTable ORDER BY [GroupTypes];

This will permit additional GroupTypes to be included as they are
added to your table.

Then code the Combo's AfterUpdate event:
Me.Filter = "[GroupTypes] = '" & Me!ComboName & "'"
Me.FilterOn = True

That should do it.
When you open the form and select the letter from the combo box, only
those records with the GroupType with that letter will be shown in the
form.

To then view all the records, simply click the Apply Filter Tool
Button, or Right-Click on the form and select 'Remove Filter/Sort'.
 
Back
Top