Form Undo vs Data Controls

J

JohnWL

I have a form in Access 2002 on which some controls alter
properties of other controls based on the value of the
data. Ex: If the user selects choice 1 in a combo box, non-
applicable controls are set to invisible. Choice 2 sets
them back to visible.

If the user edits data in an existing record, then clicks
an Undo (Cancel) command button or uses the Escape key,
the form's Undo event triggers. I want code to then run
which also resets the properties of those other controls
as well. But the data in those controls does not get reset
until after the Undo event finishes. Thus, the code is
still reading the edited data, not the original data. No
event I can find is triggered after the form's Undo event,
so I can't place such code anywhere else effectively.

How can I call subroutines that reset the properties of
the other controls after the data in the primary controls
is undone?
 
A

Allen Browne

As you found, the Value of the controls has not been set at the time
Form_Undo fires.

Check the OldValue of the controls instead.
 
J

JohnWL

Allen, Thanks for the tip. It worked perfectly. Its a property I knew about,
but it just hadn't come to my mind while I worked on this myself.

As I started to try it today, I was stumped at first because I have
sub-routines that set these other controls based on current values. So I
couldn't just call them, and neither could I modify them to use OldValue
which would cause other calls to them to use the wrong values. So I set each
control variable which they require back to the old value in the form's Undo
procedure before calling the sub-routines. That solved it, allowing those
subs to work for all situations.

You may be pleased to know that I browsed your web site and found other tips
there that I really like and made notes to use in the future. And I referred
several others in these newsgroups to specific tips on your web site to
answer their questions as a result of seeing what all you have there.

Anyway, thanks again.
John Loewen
 

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