I'm trying to create a Auto-fill Textbox where my users are restricted to options that are already present in a pre-populated list of Assets.
I've managed to make it work to the point that when they start typing the letters the Listbox shows up with possible matches and if they double click on a particular match that get's selected and entered into the text box and they can continue.
I got early feedback though that the users in my firm would prefer if they could use the down arrow and then press enter to select the Asset from the list box.
Here's the code I'm using to make that happen:
However while it works smoothly for Double Click it fails for Keypress giving me the error:
Automation Error
The object invoked has disconnected from its clients
I understand it might be complex to answer without the file so I've made that available at this link:
Blotter v3.xlsm
Would appreciate any ideas to making it work! Thanks!
I've managed to make it work to the point that when they start typing the letters the Listbox shows up with possible matches and if they double click on a particular match that get's selected and entered into the text box and they can continue.
I got early feedback though that the users in my firm would prefer if they could use the down arrow and then press enter to select the Asset from the list box.
Here's the code I'm using to make that happen:
VBA Code:
Private Sub lbAssetID_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
Dim i As Long
If KeyAscii = 13 Then
With Me.lbAssetID
For i = 0 To .ListCount - 1
If .Selected(i) Then
Me.tbAssetID.Value = .List(i, 0)
lbAssetID.Visible = False
Exit For
End If
Next
End With
End If
End Sub
However while it works smoothly for Double Click it fails for Keypress giving me the error:
Automation Error
The object invoked has disconnected from its clients
I understand it might be complex to answer without the file so I've made that available at this link:
Blotter v3.xlsm
Would appreciate any ideas to making it work! Thanks!