I have a continuous form with my record source as a query. The query has been set up so that the criteria for the field named "Inventory Type" is being defined by a combo box.
I have this working just fine by using this in the criteria.
[Forms]![Search Inventory]![combotype] OR [Forms]![Search inventory]![combotype] IS NULL
Now I am trying to create a search bar so that AFTER all of the inventory has been filtered the user can search through it to find what they need. However, the code I am using is messing with the combobox filter I have set up. It doesnt work when I have the search bar and code in the form..
This is the search bar code I have set up.
Private Sub searchbox_Change()
Dim strFilter As String
On Error GoTo ErrHandler
If Me.searchbox.Text <> "" Then
strFilter = "[Part description] Like '*" & Me.searchbox.Text & "*'
OR [part number] Like '*" & Me.searchbox.Text & "*'
OR [1st vendor] Like '*" & Me.searchbox.Text & "*'
OR [1st price] Like '*" & Me.searchbox.Text & "*'
OR [2nd part number] Like '*" & Me.searchbox.Text & "*'
OR [2nd vendor] Like '*" & Me.searchbox.Text & "*'
OR [2nd price] Like '*" & Me.searchbox.Text & "*'
OR [3rd part number] Like '*" & Me.searchbox.Text & "*'
OR [3rd vendor] Like '*" & Me.searchbox.Text & "*'
OR [3rd price] Like '*" & Me.searchbox.Text & "*'"
Me.Filter = strFilter
Me.FilterOn = True
Else
Me.Filter = ""
Me.FilterOn = False
End If
With Me.searchbox
.SetFocus
.SelStart = Len(Me.searchbox.Text)
End With
Exit Sub
ErrHandler:
MsgBox Err.Description, vbExclamation
End Sub
Does anyone know how I can BOTH of these things to work? It would make searching and filtering a lot easier. Thanks in advance.
I have this working just fine by using this in the criteria.
[Forms]![Search Inventory]![combotype] OR [Forms]![Search inventory]![combotype] IS NULL
Now I am trying to create a search bar so that AFTER all of the inventory has been filtered the user can search through it to find what they need. However, the code I am using is messing with the combobox filter I have set up. It doesnt work when I have the search bar and code in the form..
This is the search bar code I have set up.
Private Sub searchbox_Change()
Dim strFilter As String
On Error GoTo ErrHandler
If Me.searchbox.Text <> "" Then
strFilter = "[Part description] Like '*" & Me.searchbox.Text & "*'
OR [part number] Like '*" & Me.searchbox.Text & "*'
OR [1st vendor] Like '*" & Me.searchbox.Text & "*'
OR [1st price] Like '*" & Me.searchbox.Text & "*'
OR [2nd part number] Like '*" & Me.searchbox.Text & "*'
OR [2nd vendor] Like '*" & Me.searchbox.Text & "*'
OR [2nd price] Like '*" & Me.searchbox.Text & "*'
OR [3rd part number] Like '*" & Me.searchbox.Text & "*'
OR [3rd vendor] Like '*" & Me.searchbox.Text & "*'
OR [3rd price] Like '*" & Me.searchbox.Text & "*'"
Me.Filter = strFilter
Me.FilterOn = True
Else
Me.Filter = ""
Me.FilterOn = False
End If
With Me.searchbox
.SetFocus
.SelStart = Len(Me.searchbox.Text)
End With
Exit Sub
ErrHandler:
MsgBox Err.Description, vbExclamation
End Sub
Does anyone know how I can BOTH of these things to work? It would make searching and filtering a lot easier. Thanks in advance.