Hi all,
I have a combobox on my data entry form. When a user types, the list section of the form auto-refreshes to display items containing the text. However, when a user then selects an item using the arrow keys, it automatically updates the text region. This isn't good for my purpose as it doesn't allow users to select items in the list box section beyond the top option. Is there a way to prevent this from happening?
I will post my code below for the auto-refreshing of the combobox to see if the problem lies in there but I don't think it's related to that.
I have a combobox on my data entry form. When a user types, the list section of the form auto-refreshes to display items containing the text. However, when a user then selects an item using the arrow keys, it automatically updates the text region. This isn't good for my purpose as it doesn't allow users to select items in the list box section beyond the top option. Is there a way to prevent this from happening?
I will post my code below for the auto-refreshing of the combobox to see if the problem lies in there but I don't think it's related to that.
Code:
Private Sub cmdLocationID_Change()
Me.cmdLocationID.RowSourceType = "Value List"
Dim db As Database
Dim qdf As QueryDef
Dim rs As DAO.Recordset
Dim intX As Integer
Set db = CurrentDb()
Set qdf = db.QueryDefs("qrySearchType")
qdf.Parameters("SearchTXT") = Me.cmdLocationID.Text
Set rs = qdf.OpenRecordset()
'remove all items in the combo box before querying to add them
With rs
With Me.cmdLocationID
For intX = .ListCount - 1 To 0 Step -1
Call .RemoveItem(intX)
Next intX
End With
End With
'any results = add to list box
If rs.RecordCount <> 0 Then
With rs
.MoveFirst
While Not .EOF
Me.cmdLocationID.AddItem .Fields("LocationID") & ";" & .Fields("FileLocation")
.MoveNext
Wend
End With
End If
rs.Close
db.Close
Set rs = Nothing
Set db = Nothing
If Nz(Me.cmdLocationID.Text, "") <> "" Then
Me.cmdLocationID.Dropdown
End If
End Sub
Comment