Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I have a problem creating a toggle button script.

Status
Not open for further replies.

Wadoki

IS-IT--Management
May 15, 2001
135
US
I want to make a screen that looks like the one below. I want to use toggle buttons to filter the report to show if someone has completed there part of the process.

I have created the page and the sub page, I just don't know how to make the toggle buttons turn on and off the rule and refresh the report.

Can anyone help?

 
I assume if the user toggles "Show Production" it filters the records to show where productionApproval = true. Is that correct?

Can the user click more than one toggle? ie. where productionApproval = true and technicalApproval = true. Or do you want this to work like an option group where you can only click one toggle?
 
If you want to only choose one selection at a time, this is very easy.
1) Use an option group for your toggle buttons, not individual toggle buttons.
2) Select "toggle button" for the format of the option group
3) Each toggle returns a value of 1,2..n so use a select case statement

my option group is called "optFilter" and the subform is called "subFrmApproval".

Code:
Private Sub optFilter_AfterUpdate()
  Select Case optFilter
  Me.subFrmApproval.Form.FilterOn = True
    Case 1
      Me.subFrmApproval.Form.Filter = "productionApproval = True"
    Case 2
      Me.subFrmApproval.Form.Filter = "technicalApproval = True"
    Case Else
       Me.subFrmApproval.Form.FilterOn = false
End Select

End Sub

My 3rd button is labled "Remove Filter" and is handled by the "Case else" statement.
 
Multiple Selections, so multiple filters...
 
Code:
Private Sub tglProduction_Click()
  Call filterRecords
End Sub

Private Sub tglRateWaste_Click()
  Call filterRecords
End Sub

Private Sub tglTechnical_Click()
  Call filterRecords
End Sub

Public Sub filterRecords()
  Dim strProduction As String
  Dim strRateWaste As String
  Dim strTechnical As String
  'etc
  Dim strFilter As String
  
  If Nz(tglProduction, 0) Then
    strProduction = "productionApproval = true AND "
  End If
  If Nz(tglTechnical, 0) Then
    strTechnical = "technicalApproval = true AND "
  End If
  If Nz(tglRateWaste, 0) Then
    strRateWaste = "rateWasteApproval = true AND "
  End If
  'etc
  
  strFilter = strProduction & strTechnical & strRateWaste
  If Len(strFilter) > 0 Then
    strFilter = Left(strFilter, Len(strFilter) - 5)
    With Me.subFrmApproval.Form
      .Filter = strFilter
      .FilterOn = True
    End With
  Else
    With Me.subFrmApproval.Form
      .Filter = ""
      .FilterOn = False
    End With
  End If
  'Debug.Print strFilter
  
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top