Hello everyone
I have a datasheet in split form view. I've added some functionality to it by including a search bar that filters the datasheet based on whatever the user types in. As well as two combo boxes that filter the datasheet based on whatever the user selects. Everything works fine and dandy except for one small thing. Whenever the user makes a selection in either combo box, the functionality of the search box disappears. Here's the VBA for each search option
For the search bar:
First combo box:
Second combo box:
And this is the reset button vba:
If i type something in, nothing happens. Does anyone know why this is? Thank you!
PS Thank you Ridders for helping with the combo box vba
I have a datasheet in split form view. I've added some functionality to it by including a search bar that filters the datasheet based on whatever the user types in. As well as two combo boxes that filter the datasheet based on whatever the user selects. Everything works fine and dandy except for one small thing. Whenever the user makes a selection in either combo box, the functionality of the search box disappears. Here's the VBA for each search option
For the search bar:
Code:
Private Sub SrchText_AfterUpdate()
Me.SrchText.Requery
End Sub
Private Sub txtSearch_Change()
'Create a string (text) variable
Dim vSearchString As String
vSearchString = txtSearch.Text
SrchText.Value = vSearchString
If Len(Me.SrchText) <> 0 And InStr(Len(SrchText), SrchText, " ", vbTextCompare) Then
Exit Sub
End If
'Me.SearchResults = Me.SearchResults.ItemData(1)
'Me.SearchResults.SetFocus
DoCmd.Requery
Me.txtSearch.SetFocus
If Not IsNull(Len(Me.txtSearch)) Then
Me.txtSearch.SelStart = Len(Me.txtSearch)
End If
End Sub
First combo box:
Code:
Private Sub ComboWSIB_AfterUpdate()
Select Case Me.ComboWSIB.Value
Case "All"
Me.FilterOn = False
Case Else
'filter all values where ComboWSIB value is in WSIB Employer Declaration Complete? field string
Me.Filter = "InStr([WSIB Employer Declaration Complete?],""" & Me.ComboWSIB.Value & """)>0"
' Debug.Print Me.Filter
Me.FilterOn = True
End Select
Second combo box:
Code:
Private Sub CboPrograms_AfterUpdate()
Select Case Me.CboPrograms.Value
Case "All"
Me.FilterOn = False
Case Else
'filter all values where cboFilter value is in Complete field string
Me.Filter = "InStr([Program(s)],""" & Me.CboPrograms.Value & """)>0"
' Debug.Print Me.Filter
Me.FilterOn = True
End Select
End Sub
And this is the reset button vba:
Code:
Private Sub cmdReset_Click()
Me.txtSearch = ""
Me.SrchText = ""
Me.txtSearch.SetFocus
DoCmd.Requery
End Sub
If i type something in, nothing happens. Does anyone know why this is? Thank you!
PS Thank you Ridders for helping with the combo box vba