AfterUpdate / On Change Problem

  • Thread starter Thread starter Joe Williams
  • Start date Start date
J

Joe Williams

In an earlier post I was having difficulty setting up a filter for a subform
based on the criteria from a text box ont he main form. What I was trying to
do was to be anle to enter "W" in teh main box and have records beginning
with W appear in the subform. Then, ifI continue ot type "Wi" then recrds
beginning with Wi would show up in the subform.

I have modified the recordsource of the subform and the afterupdate/On
change event of the text box on the main form so that it requeries when the
text box is altered.

The problem I am having is that even though the on change event fires, it
seems as though the valu of the text box does no change until the focus
leaves the control. For instance, if I type W in the text box, the on change
event fires (I put a msgbox there) but the value of the control is null at
that point. If I put a .setfocus to some other control and then do a msgbox,
I get the correct value "W" from the text box.

Now, this is an issue because the desired operation of the form is that the
user can start typing a name into the text box and it will continually
requery the subform as the user types letters, thereby narrowing in on the
records the user is looking for.

how can I make this work as desired, if the control does not see the extra
characters entered until the control has lost focus?

Thanks
joe
 
Joe Williams said:
In an earlier post I was having difficulty setting up a filter for a subform
based on the criteria from a text box ont he main form. What I was trying to
do was to be anle to enter "W" in teh main box and have records beginning with
W appear in the subform. Then, ifI continue ot type "Wi" then recrds beginning
with Wi would show up in the subform.

I have modified the recordsource of the subform and the afterupdate/On change
event of the text box on the main form so that it requeries when the text box
is altered.

The problem I am having is that even though the on change event fires, it
seems as though the valu of the text box does no change until the focus leaves
the control. For instance, if I type W in the text box, the on change event
fires (I put a msgbox there) but the value of the control is null at that
point. If I put a .setfocus to some other control and then do a msgbox, I get
the correct value "W" from the text box.

Now, this is an issue because the desired operation of the form is that the
user can start typing a name into the text box and it will continually requery
the subform as the user types letters, thereby narrowing in on the records the
user is looking for.

how can I make this work as desired, if the control does not see the extra
characters entered until the control has lost focus?

Until the control loses focus you have to use the Text property instead of the
Value property. Text contains the edited (but not yet updated) contents of the
control and is only available when the control has focus.
 
Back
Top