OnType event for TextBox?

  • Thread starter Thread starter bhammer
  • Start date Start date
B

bhammer

Presently: The user types the desired prefix into the txtPrefix and then
clicks cmdAddPrefix which runs an update query that adds the Prefix text to
each filename in a listbox displaying a list of filenames.

Goal: Run the update query on each keystroke--sort of a live update--to
instantly show the results of the Prefix text, as each character is typed or
deleted.

Is there an OnType event?? I've tried OnKeyPress, OnChange, etc. but it only
works one time. . .
 
Got it. The OnChange event is what I need. The text in the textbox was not
being read because I had, "Me.txtPrefix". It works now that I changed it to,
"Me.txtPrefix.Text".
 
bhammer said:
Presently: The user types the desired prefix into the txtPrefix and then
clicks cmdAddPrefix which runs an update query that adds the Prefix text
to
each filename in a listbox displaying a list of filenames.

Goal: Run the update query on each keystroke--sort of a live update--to
instantly show the results of the Prefix text, as each character is typed
or
deleted.

Is there an OnType event?? I've tried OnKeyPress, OnChange, etc. but it
only
works one time. . .


You might use the Change event or the KeyPress event, but note that they
behave differently. I'd probably use the Change event, if I were you. In
the Change event, the Text property of the control is what you should be
checking -- it will reflect the text currently displayed in the control.
Don't use the text box's Value property in that event, as that value won't
be updated until the user exits the control.

In the KeyPress event, check the KeyAscii argument to see what key has just
been pressed. Note that this will be a numeric ASCII value, not a string
value.

If your code isn't working as you think it should, I suggest you review your
code -- maybe set a breakpoint and step through it, watching to see what
variable values are set and what happens.
 
Back
Top