Cancel, Undo and Null

  • Thread starter Thread starter RzB
  • Start date Start date
R

RzB

I have a simple form that has an add, edit, save
and cancel button and a couple of text boxes
bound to a table.. The cancel button is there
so that the user can decide to cancel out of
any edditing/adding situation that he may be in.
All works OK except one instance.

If the user has deleted the data in a text box
(making it null) and then attempts to hit the cancel
button, the the form on error fires and gets in the
way. I never get to the Cancel button click event.
How do I program round this so that when the
cancel button is clicked, no matter what the
situation is with the text boxes, I can do an
undo and go back to a normal state.

Using Access 2002 & DAO

Thanks,
Roy
 
That's correct: if you place a command button on the form, you cannot get
out of a required field to get to the cancel button by backspacing the
characters.

Instead, undo the entry by pressing the <Esc> key.
Or by clicking the Undo button on the Toolbar.
Or by choosing Undo from the Edit menu.
 
Allen,

Hmm... That's a bit naff - The user is going to hit the
Cancel button and and it's not going to Cancel.
So is there no way to simulate the escape key, or
clicking the Undo button on the Toolbar, or choosing
Undo from the Edit menu in VBA ?
I suppose I could always hunt for the rouge text
box with a null in it, and put something in it and
then do the undo. Trouble is I don't know if it's
the Save button or the Cancel button that has
been hit,

Hmmm

Thanks for your help,
Roy
 
The issue is that you cannot get the Click event of the button to fire
without Access processing the events for the control that already has focus.

It follows that putting a Cancel button on a bound form is not a very useful
thing to do.
 
Hmm.. Yes I can see what you mean.. I suppose the thing to do
is make it unbound and handle all the updating in code..

I did manage to know which button had been clicked or
pressed by setting/clearing a flag in the MouseMove and
GotFocus events of the Save and Cancel buttons.
But that didn't help because it seems that you can't do
anything useful from within the OnError event anyway !
I'm sure there must be a way - setting a timer or something
to run some code outside the OnError event, but life is too short :-)

I've added a MsgBox to the OnError event to tell the user
to hit the Escape key, and where to find it on the keyboard :-)

Many thanks for your help,
Roy
 
Back
Top