Solved

Toggle Buttons!!!

Posted on 2001-09-12
6
607 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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

896 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

18 Experts available now in Live!

Get 1:1 Help Now