Solved

Toggle Buttons!!!

Posted on 2001-09-12
6
612 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 58
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 58
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
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
LVL 58
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 58

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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

707 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