Full Version: Basic filter with a toggle button
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
Tomo1
I have a form that I wish to have toggle buttons at the top.

The toggle buttons will filter my list of contacts and provide customers, competitors or suppliers based on a single list of contacts. There is are separate yes/no fields for whether a contact is a customer, competitor or supplier. This allows a contact to potentially be any combination of the three.

With my form open, showing all contacts I have a toggle button group but am unsure how to make each button filter.

I've started in the After Update for the group and used - Select ContactGroup....Case 1.....End select.

Does anyone know what code I should use to do these single field filters? Or has anyone ever tried anything similar that I could get an idea from?
NorthNone
I've used variations of this filtering code many times. Great stuff! Fortunately I included references to the source in my code, so I could find it quickly for you.
http://home.clara.net/tkwickenden/coding.htm
Look down the page for
acCmdFilterByForm Filter Records Using The Filter By Form Method
acCmdFilterBySelection Filter By Selection
acCmdFilterExcludingSelection Filter Excluding Selection
Jack Cowley
If you have 3 check boxes in each record for Customer, Competitor or Supplier then you have repeating groups and you need to restructure your data. These three items should be separate records in a related table. IF, on the other hand, a record can ONLY be a Customer, Competitor or Supplier and NEVER two of those choices then you should have a foreign key field that stores the Primary key for a table where the records are Customer, Competitor or Supplier.

If you normalize your structure it will be very easy to filter your data by selecting the type (Customer, Competitior, Supplier) from a list or combo box...

Just my 3 cents worth...

Jack
Tomo1
Thanks Jack, it did occur to me that I should do as you suggested and split the "contact types" off but the way I want to display this information (going across the page rather than down it) and since a contact will only ever be one or some of these choices I decided to lump them all in the same table. Not entirely correct but simplest at this stage.

Thanks NorthNone - I'm looking at that website now!
Jack Cowley
Since you are aware that your data is not normalized then go for the gusto!

Jack
Tomo1
Cheers Jack!
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.