OnType event for TextBox?

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. . .
 
B

bhammer

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".
 
D

Dirk Goldgar

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top