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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Restore Former Unbound Text Box Value 1

Status
Not open for further replies.

dftjsn

Programmer
Feb 25, 2002
43
US
I'd like to restore the value of an unbound text box when I cancel its before update event. It appears Access leaves the errant value in the unbound text box after the event is cancelled. I'd like to set it back to its former value which I have stored in a public variable, not the errant value. Does anyone know how to make this happen?

Thanks!

dftjsn
 
Hi dft,

In the 'Before_Update' event, you set Cancel = True to cancel the update - yeah? You obviously know that.

The control can be 'undone' by saying:

control.Undo

e.g. txtMyDate.Undo

So if txtMyDate had 12/05/2002 in it, I change it to 12/06/2007 - your code kicks in and Undoes it - the value returns to 12/05/2002.

Good eh? (Just learned that the other day!).

Hope this helps.

Regards,

Darrylle "Never argue with an idiot, he'll bring you down to his level - then beat you with experience."
 
Darrylle,

Thanks for your response. The Control.Undo command you describe does return the original value to a bound control during the before_update event. Unfortunately, I've got an unbound text box. When I cancel the before_update event and do Control.Undo, the unbound text box retains the errant value. The control.oldvalue property doesn't work with unbound text boxes either. I do have the former value in a global variable, but can't reassign it during the before_update event.

Any other ideas short of doing away with the unbound text box?

Thanks!

dftjsn
 
How about the OldValue property? This is described as pertaining only to bound controls, but it definitely has a value once an unbound text box has been updated (by moving to a different control, for example). This makes me think it remains available during the BeforeUpdate procedure, while the value of the control itself has been provisionally changed to what's showing in it.
 
Duck72,

Good thought, but you can use the OldValue property to determine the unedited value of a bound control.

dftjsn
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top