Unexpected Behavior with Textbox Text Property
Posted on 2011-02-22
I have created an unbound textbox on a form that can be used for freeform searching. If the user types something in the box, the RowSource for a neighboring listbox is re-written that includes the string in the box. I've done this many times, but it's not working for some reason. I am monitoring the textbox's _Change event. Since the textbox has the focus, the Text property should yield the text in the box (i.e. NOT the Value property). But Access tells me that the textbox must have the focus in order to reference that property. Well, that's true, but the textbox DOES have the focus.
I can even test it with this:
If Me.ActiveControl.Name = Me.tbxSearch.Name Then STR = Trim(Me.tbxSearch.Text)
This ought to work, right? It fails.
Access thinks that the textbox has the focus, but tells me otherwise. In fact, not even me.tbxSearch.SetFocus solves the problem.