detecting menu-operations with VBA

G

Guest

My native language isn't English, so I'd like to appologise in advance for
any spelling mistakes I've made.

I created a form wich modifies the appearance of certain controls depending
on the value of one field.
More in detail: The form has (amongst other things) a textfield based on an
integer number.
1)If the textfield contains data there will be a spinbutton next to this
textfield which can be used to modify the content of the textfield .
2)If the textfield contains no data (=Null) there will be a commandbutton
next to this textfield which can be used to put a default value into the
textfield.
3)When the textfield get erased, the spinbutton disappears and is replaced
by the commandbutton.
4)When valid data is entered in the textfield, the commandbutton disappears
(if it was still there) and is replaced by the spinbutton.

To modify the visibilty and other properties of these two buttons, I use the
OnChange event and the AfterUpdate event of the textfield (and some other
events too).
All this stuff is working all right as long as the user operates the
(visible) buttons or modifies the value in the textfield with the keyboard.
As soon as the 'Undo ...'-command from the edit-menu is used, the buttons on
my form don't follow the changes of the texfield anymore. Although the
textvalue of the texfield is changed (on screen), this doesn't trigger any of
the events which I programmed to update the buttons on the form.

Does anyone know how VBA can detect (these) menu-operations?
By detection of menuactions I can update my form in any situation.

Thanks in advance
 
P

Paul Overway

Your English is better than a lot of native English writers that post on
here! :blush:)

I've encountered similar situations as you describe, and short of
subclassing commandbars or using timer events, I'm unaware of any other
method to address the problem. We need a form level undo event.

For the timer based solution, set the timer interval once the form becomes
dirty, and then periodically check whether the form is still dirty in the
Form_Timer event and reset everything back to its normal state, if an undo
occur.
 
G

Guest

Thanks for the reply Paul

Today I found a solution on the Microsoft Knowledge database. In the article
Q210326 Microsoft describes how to create a form_AfterUndo event.
 

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