Link to home
Start Free TrialLog in
Avatar of scorp8
scorp8Flag for United States of America

asked on

Toggle Buttons!!!

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?
Avatar of Jim Dettman (EE MVE)
Jim Dettman (EE MVE)
Flag of United States of America image

Sure. Can you outline what your trying to do or send a sample?

Jim.
Avatar of scorp8

ASKER

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

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.
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.
Avatar of scorp8

ASKER

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  

ASKER CERTIFIED SOLUTION
Avatar of Jim Dettman (EE MVE)
Jim Dettman (EE MVE)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial