Solved

Toggle Buttons!!!

Posted on 2001-09-12
6
606 Views
Last Modified: 2010-05-18
I have a form with two toggle buttons...

on this form, there are certain records that have checks beside them.  I would like to be able to use the toggle buttons as preset filters but I can't seem to get it to work properly...  anyone familiar with coding toggle buttons to filter specific data?
0
Comment
Question by:scorp8
  • 4
  • 2
6 Comments
 
LVL 57
ID: 6477258
Sure. Can you outline what your trying to do or send a sample?

Jim.
0
 
LVL 1

Author Comment

by:scorp8
ID: 6477297
Example:  I have a form with 1000 records and two toggle buttons.  

Of the 1000 records, about 750 records do not need to be seen if the user elects not to see them.  In other words, one toggle button will filter out 375 and the other will filter out the other 375.  But if the user want's to see all 1000 records, he can deselect the buttons..  (Just like the normal filter by selection process in Access)

HTH

scorp8

0
 
LVL 57
ID: 6477332
There are a multitude of ways to do this. I'll give you one.  Let's say you want to sort a phone book, and provide 26 buttons, one for each letter and one additonal for "ALL".  By placing these in a group, only one can be choose at a time.

  In the groups AfterUpdate event, checking the group controls value would tell you which is pushed.  Based on that, you would set the forms filter property.  Something like:

Me.Filter = "Like 'A'"
Me.FilterOn = True
 
  a slightly better way to do that is:

strFilterLetter = Mid(Me![grpAlpha],"abcdefghijk...z*")

Me.Filter = "Like '" & strFilterLetter & "'"
Me.FilterOn = True

This is just one example.  You could also reset the forms underlying recordset and build an SQL statement on the fly.  Here's an example of changing a sort order based on toggle buttons as column headers:

    ResetRecordSource = True

    strRecordSource = "SELECT DISTINCTROW * FROM qryfrmLoadSummarySF"
    If IsNull(Me![SQLWhereClause]) Then Me![SQLWhereClause] = ""
    If (Me![btnRemoveFilter].Enabled) And Len(Me![SQLWhereClause]) > 0 Then strRecordSource = strRecordSource & " WHERE " & Me![SQLWhereClause]
    strFields = "LoadID        SchDateTime   Status        Dispatcher    OrigName      DestName      Description   BillTo        Orig          Dest          OrigRef       DestRef       "
    strRecordSource = strRecordSource & " ORDER BY " & Mid$(strFields, 14 * Me![grpSortBtns] - 13, 14)
    If Me![grpSortBtns] = 2 Then strRecordSource = strRecordSource
    strRecordSource = strRecordSource & ";"
    On Error GoTo Invalid_filter
    Me![embfrmLoadSummarySubForm].Form.RecordSource = strRecordSource
    On Error GoTo 0


That help?

Jim.
0
Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

 
LVL 57
ID: 6477343
Oops! two corrections:

1. I meant "filter" instead of sort in the first example.
2. I forgot to include a field in the filter clause (it's a WHERE statement without the word WHERE):

Me.Filter = "CustomerName Like 'A*'"
Me.FilterOn = True


Jim.
0
 
LVL 1

Author Comment

by:scorp8
ID: 6477375
this is what i had in mind and what I had before i asked EE.  

Currently in my form, in addition to the columns I have now, I have added two new columns set as yes/no data types.

on my upload of the 1000 records, the 375 records I'm setting up for the filter have been set to true, as well as the other 375 in the other yes/no column.  In simple terms, I have one column with 375 of 1000 records set to true, and the 2nd column doing the same.

how could I set my toggle button to take out the rows set to true in my form when I "key down", then place them back when I "key up"?

scorp8  

0
 
LVL 57

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 20 total points
ID: 6477396
Add the following Subroutine to the form:

Private Sub SetFilter()

 If Me![tgl1] = False and Me![tgl2] = False then
   Me.FilterOn = False
 ElseIf Me![tgl1] = True and Me![tgl2] = True then
   Me.Filter = "<Column1> = True AND <column2> = True"
   Me.FilterOn = True
 ElseIf Me![tgl1] = True then
   Me.Filter = "<Column1> = True"
   Me.FilterOn = True
 Else
   Me.Filter = <column2> = True"
   Me.FilterOn = True
 End If

 I believe is what your asking for.

Jim.
 
 

0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now