Babycat
Member
- Local time
- Today, 06:52
- Joined
- Mar 31, 2020
- Messages
- 285
Dear all
I have an unbound textbox names: Txt_FnameFilter, it functions a search for each character keyed in via function: User_FnameFilterParameter (Txt_FnameFilter.text)
This error occurs when no search result found.
I have read about Error 2185, i understand that I can not access Txt_FnameFilter.text when Txt_FnameFilter is not an active control.
However, as the screenshot showing, the control already got focus, but why I still could not access Txt_FnameFilter.text?
It introduces runtime error when i type in immediately window.
.
I have an unbound textbox names: Txt_FnameFilter, it functions a search for each character keyed in via function: User_FnameFilterParameter (Txt_FnameFilter.text)
This error occurs when no search result found.
I have read about Error 2185, i understand that I can not access Txt_FnameFilter.text when Txt_FnameFilter is not an active control.
However, as the screenshot showing, the control already got focus, but why I still could not access Txt_FnameFilter.text?
It introduces runtime error when i type in immediately window.
Code:
Private Sub Txt_FnameFilter_KeyUp(Keycode As Integer, Shift As Integer)
'On Error GoTo ErrorHandler
Dim prevtext As String
Txt_FnameFilter.SetFocus
If Nz(Txt_FnameFilter, "") <> Nz(Txt_FnameFilter.text, "") Then ' this is to avoid searching when press non-character keys such arrow keys
prevtext = Txt_FnameFilter.text
User_FnameFilterParameter (Txt_FnameFilter.text)
Txt_FnameFilter.SetFocus
Txt_FnameFilter = prevtext
Txt_FnameFilter.SelStart = Len(prevtext)
End If
UserExitSF:
Exit Sub
ErrorHandler:
'MsgBox "There is an error occurred: " & Err.Number & ": " & Err.Description, vbOKOnly + vbCritical
Resume Next
End Sub