Unable to undo changes when control lost focus

JenSGT

Registered User.
Local time
Today, 03:09
Joined
Jul 26, 2009
Messages
20
I have a combo_OrderID button with a OnChange event. In the OnChange event, I would check for a IsFormDirty Flag. If the flag is set, I will proceed to undo the changes on all the controls on the form.
I use a "Me.undo" to undo the changes in the control.

And all the controls have bound data sources.

The code works perfectly whenever I click on the combo_OrderID button which is currently the focus in the form.

I build the same code in another combo_CustID button. After I first clicked on combo_OrderID button, dirty the form, then I clicked on the combo_CustID button(now, the focus). This will cause the dirty data to be saved.

Why is "Me.undo" unable to undo the changes?

If I clicked on combo_OrderID button, dirty the form, then I clicked on the
combo_OrderID button, the dirty data will not be save.

Has this got to do with the control in focus?
 
You should probably not be using the OnChange event for your undo as it can fire everytime someone even types a character in the combo. You may want to use the click event which would fire when they click in the combo. But I guess if it works for you, you can use that one.

For validations, you should use the Before Update event. Not the Lost Focus event. By that time the record has saved. So, in your form's before update event you can do a

Cancel = True
Me.Undo

if you want to undo any changes to the form BEFORE they get saved.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom