Contents of text box do not change in OnChange event.

G

Guest

This has puzzled me for along time.

When inside the OnChange event code of a text box the value does not change.

How do I know what has been typed in?

eg Blank new form, add text box (txtText) , unbound, set up the OnChange
event, debug at End Sub, run, type in the letter 'g', program breaks, txtText
is null.

Focus outside the text box, focus inside, add letter 'k' (to the 'g'), view
contents at break point, they are 'g'.

What is the point of the OnChange event?
 
R

Rick Brandt

ThomasAJ said:
This has puzzled me for along time.

When inside the OnChange event code of a text box the value does not change.

How do I know what has been typed in?

eg Blank new form, add text box (txtText) , unbound, set up the OnChange
event, debug at End Sub, run, type in the letter 'g', program breaks, txtText
is null.

Focus outside the text box, focus inside, add letter 'k' (to the 'g'), view
contents at break point, they are 'g'.

What is the point of the OnChange event?

Value doesn't change until you tab out. For the temporary value use the Text
property.
 
S

Someone

OnChange makes code run when the value of the saved information in the
control has changed.

I've used it, for example, to change fonts or colours when the contents of a
text box changes.

M
 

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