How to Program a Cancel Button

  • Thread starter Thread starter Scott A
  • Start date Start date
S

Scott A

I've got a few forms that I'm using as pop-ups, that I
would like to give the traditional 'OK' and 'Cancel'
behaviors.

My problem is that I don't quite like the behaviors behind
the Cancel button - I've used the Undo Record behaviors
using the command wiz.

When the user clicks Cancel to close a form that has no
data, they get a message saying that Undo is not
available..., Changing the message text isn't what I want
to go for either.

What I would like is a little VBA that trashes anything
the user may have entered into the form if they click
cancel, and doesn't pop up any error messaging if the form
is still blank.

Anybody?

Scott A
 
Use your Undo code. At the beginning of the code put:
On Error GoTo ExitHere
and at the line right before End Sub put:
ExitHere:

Note: Be sureto include the colon after ExitHere!
 
Thanks for the tip. I assume that the rest of the error
handling code should be deleted?

Scott
 
Or should I leave it in? When I made the modifications
you suggested to the Undo behaviors of the button, all it
does now is clear the form. Is there something else I can
add that will both clear the form and close it?

Thanks,

Scott
 
Back
Top