Contents of text box do not change in OnChange event.

  • Thread starter Thread starter Guest
  • Start date Start date
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?
 
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.
 
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
 
Back
Top