abenitez77
Registered User.
- Local time
- Today, 12:22
- Joined
- Apr 29, 2010
- Messages
- 141
I have a form in ms access 2016 with a subform in datagrid view. In that datagrid, I have a column that is a combobox and I am filtering the values as you type. It works for the first selection, but when I make my selection and I want to either go to the next record and make another selection or change the selection I made in my current row, all the values disappear and are blank. This is my code:
Option Compare Database
Private Const RecordSQL As String = "SELECT ConID, ItemNo, Description FROM Consignment"
Public Sub FilterComboAsYouType(combo As ComboBox, defaultSQL As String, lookupField As String)
Dim strSQL As String
If Len(combo.Text) > 0 Then
strSQL = defaultSQL & " WHERE " & lookupField & " LIKE '*" & combo.Text & "*'"
Else
strSQL = defaultSQL 'This is the default row source of combo box
End If
combo.RowSource = strSQL
combo.Dropdown
End Sub
Private Sub Select_Item_AfterUpdate()
'reset dropdown list
Select_Item.RowSource = RecordSQL
Select_Item.Requery
Select_Item.Dropdown
Select_Item.SetFocus
End Sub
Private Sub Select_Item_Change()
FilterComboAsYouType Me.Select_Item, RecordSQL, "Description"
End Sub
Option Compare Database
Private Const RecordSQL As String = "SELECT ConID, ItemNo, Description FROM Consignment"
Public Sub FilterComboAsYouType(combo As ComboBox, defaultSQL As String, lookupField As String)
Dim strSQL As String
If Len(combo.Text) > 0 Then
strSQL = defaultSQL & " WHERE " & lookupField & " LIKE '*" & combo.Text & "*'"
Else
strSQL = defaultSQL 'This is the default row source of combo box
End If
combo.RowSource = strSQL
combo.Dropdown
End Sub
Private Sub Select_Item_AfterUpdate()
'reset dropdown list
Select_Item.RowSource = RecordSQL
Select_Item.Requery
Select_Item.Dropdown
Select_Item.SetFocus
End Sub
Private Sub Select_Item_Change()
FilterComboAsYouType Me.Select_Item, RecordSQL, "Description"
End Sub