2
我在键入组合框时正在构建搜索。搜索和更新使用更改事件。防止组合框选择更改文本
Private Sub ItemName_Change()
Dim strText, strFind, strSQL, strSelect, strWhere, strOrderBy As String
strText = Me.ItemName.Text
strSelect = "SELECT DISTINCT [ItemName] FROM ItemsMaster "
strWhere = "WHERE type = 'Sold Goods' "
strOrderBy = " ORDER BY [ItemName];"
If (Len(Trim(strText)) > 0) Then
'Show the list with only those items containing the types letters
strFind = "ItemsMaster.ItemName Like '"
For i = 1 To Len(Trim(strText))
If (Right(strFind, 1) = "*") Then
strFind = Left(strFind, Len(strFind) - 1)
End If
strFind = strFind & "*" & Mid(strText, i, 1) & "*"
Next
strFind = strFind & "'"
strSQL = strSelect & strWhere & "AND " & strFind & strOrderBy
Me.ItemName.RowSource = strSQL
Else
strSQL = strSelect & strWhere & strOrderBy
Me.ItemName.RowSource = strSQL
End If
Me.ItemName.Dropdown
End Sub
但是当我尝试从下拉列表中选择项目时,它会更新文本并触发更改事件。 有没有什么方法可以让用户滚动浏览列表而无需组合框更改文本框中的文本?
您是否尝试过从按键而不是组合框的更改事件运行此操作? –