I have a textbox3 for input value, and based on that value, if exist/correct focus is set on next textbox(12) if not listbox is populated with all values from a column (named range) and most similar value with that in textbox3 is selected in listbox.
After correct value is selected listbox can not unfocus. Every attempt to focus to any other object results in this error (Run-time error -2147467259 (80004005) Unspecified error).
And here is the code :
Private Sub TextBox3_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean)
Dim ws As Worksheet
Set ws = Sheets("INPUT")
If ws.Range("G3").Value = 0 Then
Label7.Caption = "This value does not exist"
ListBox1.List = [KUP].Value ' NAMED RANGE
ListBox1.Value = ws.Range("G5").Value ' SELECTS MOST SIMILAR VALUE
Else
End If
End Sub
And
Private Sub ListBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If KeyAscii = 13 Then 'KeyCode
TextBox3.Value = ListBox1.Value
Cancel = False ' tried with or without ... no change
TextBox12.SetFocus ' THIS ONE GIVES AN ERROR
End If
End Sub
I've tried every combination that crossed my mind and everything resulted in same Unspecified error.
Bookmarks