Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

'on change' I need the value BEFORE it changed

Status
Not open for further replies.

gazolba

Programmer
Dec 4, 2001
167
US
In the 'on change' event, I need the value BEFORE it changed. How to get it?
 
Hi!

The on change event of controls, fires per each keystroke, and to get to the "value" of it, use the .Text property:

[tt]Debug.Print Me!txtMyText.Text[/tt]

But I find your question a bit unclear, please specify a bit more if this doesn't address your challenge (sample data/values?).

Roy-Vidar
 
I have a combo box, so a user can change a selection. When this happens I need to write a history record on what the previous value was.

I have a hidden field which I populate whenever the control gets focus, then in the 'on change' event I compare with this hidden value. If its different, I write the history record. Is there a better way?
 
Why not just compare to the last record in the history?
 
Hi again!

The change fires when a combo is updated, but also on each keystroke (and then the contents can only be read thru the .Text property, as stated above). Perhaps the After update is better?

Your method should do the trick (but again, perhaps on the after update of the control - or the before update of the form?)

To gain the old value from a control, you might also try using:

[tt]if me!mycombo.oldvalue<>me!mycombo.value then
' it's changed, and the oldvalue
' property holds the old value
end if[/tt]

Roy-Vidar
 
My controls are all unbound, so the 'after update' event will be no good (?)
 
I'm assuming you have tried the after update, and that it failed on your setup.

This works on my setup, and I'm lead to believe that the after update of a control is supposed to fire regardless of whether it's bound or not. Might there perhaps be something wrong on your setup? Perhaps some corruption issues?

But I don't think the oldvalue property is available on unbound controls.

You could perhaps use the on got focus event to drop the existing combo value to the other textbox (or use a public variable) then use the after update to compare those.

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top