OnChange triggered before change in value

aidan

Registered User.
Local time
Today, 06:13
Joined
May 23, 2005
Messages
34
I have a combobox which needs to call a function f(combobox.value) during its onChange event. Currently though, combobox.value appears not to change before the onChange event, and so the function receives the wrong (last) value.

Note - the actual text in the text field of the combobox *has* changed to the new value before the onChange event occurs.

Any ideas why this might be?

Edit - Also the problem doesn't happen when selecting with the mouse, only when using the up and down arrow keys to move through the list.
 
Last edited:
The onChange event is the wrong event to use for this purpose. Use the combo's AfterUpdate event.
 
Thanks, it works how you would expect now - the return key works every time, and I didn't know AfterUpdate was what I needed to use...

I was however trying to have the function run every time the selection in the list changed - not after pressing return - so that the user could have instant feedback while moving through the list. Its not absolutely necessary though - the combo is just a list of keys returned from a name search (usually only one result!) so its probably better to include the middle name along with the key in the list.

Thanks again,

Aidan
 
The problem with the onChange event is that it fires for each character typed in the combo. That should produce strange results. I don't know how it handles scrolling with the mouse or up/down arrows.
 

Users who are viewing this thread

Back
Top Bottom