Close Button (Newbie)

  • Thread starter Thread starter Metastockuser
  • Start date Start date
M

Metastockuser

I'm a non programmer so I need someone that can give me very detaile
help.

I have created a button on my form that will close and save the form.


I would now like a button that would close and not save. And I want i
to work if there IS or ISN'T new data. And I don't want to get erro
messages telling me that is no data to UNDO if I use something like th
undo command is used and the user hits the close button without puttin
any data in.

I simply want a button that will close the form without saving data (i
there is or is not data) and will not have users clicking through erro
messages.

I've spent hours on this can can't figure out how to close the thin
with our without data, get no error messages and not save.

I will also need to know what form properties or button properties mus
be set to make your close suggestion work properly.

And, if anyone can step me through this....thanks much. I just don'
see what this has to be so hard
 
Ok, I found a command that I can drop into an event the did it. Thank
to Turner for providing this in another post.

If Me.Dirty Then
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
End If
DoCmd.Close

This will close a form, not save the data, and not generate erro
messages if there is nothing to clear. The If trap that looks for
dirty form and applies undo if needed works great.

Not being a programmer, I didn't have a prayer at this without help
 
DoCmd.DoMenuItem...

is old coding which may not be compatible with future Access version.
Replace it with:

Me.Undo
 
Back
Top