so i have a form which shows all the entrys of a table with a few filters on the top.
i have a text field where i can put in the name and everytime the content of the field is changed it reruns the query and brings the focus back to the field.
Private Sub FilterName_Change() Me.Requery Me.FilterName.SetFocus Me.FilterName.SelStart = Nz(Len(Me.FilterName), 0) Me.FilterName.SelLength = Nz(Len(Me.FilterName), 0) End Sub
and here the part of the query behind it:
WHERE tbl_geraete.Geraetename Like "*" &[forms]![frm_geraete]![FilterName] & "*" OR IsNull([forms]![frm_geraete]![FilterName])<>False
And it works perfectly, i can keep typing and it will alway show the relevant entrys.
but when i type in something and it doesnt find any fitting entrys i get the error:
Runtime Error 2185 You can’t reference a propert or method for a
control unless the control has focus.
if i understand this correctly somehow the set.focus doesnt work properly when there are no entrys shown in the form.
Thank you very much!