Close a form with dbCmd

J

Jack Witt

I have a form that I use to enter data into a table. I put a button at the
bottom of the form that I can use if I decide to cancel and exit the form if
I change my mind. However, when I use the Cancel button it closes the form
but also puts the data into a new record in the database. This happens even
if I blank out all the fields. I am using the dbCmd.close function. Is there
an option I can add to this function to tell it not to save? Or is there a
cancel function that would do this? I'm fairly new at this so hopefully
there is an easy way to do it.

Thanks, Jack
 
T

Tom van Stiphout

On Wed, 16 Jan 2008 20:23:59 -0700, "Jack Witt"

DoCmd.Close does the same thing as closing the form with the X in the
upper-right corner. MSFT had to choose between cancelling that record,
or saving it. They chose the latter. I would argue rightfully so.
So what you want to do in your Cancel button is first to cancel saving
the record, then close the form:
RunCommand acCmdUndo
DoCmd.Close

-Tom.
 
J

Jack Witt

Thanks, Tom. That fixed it!
Jack

Tom van Stiphout said:
On Wed, 16 Jan 2008 20:23:59 -0700, "Jack Witt"

DoCmd.Close does the same thing as closing the form with the X in the
upper-right corner. MSFT had to choose between cancelling that record,
or saving it. They chose the latter. I would argue rightfully so.
So what you want to do in your Cancel button is first to cancel saving
the record, then close the form:
RunCommand acCmdUndo
DoCmd.Close

-Tom.
 

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

Similar Threads

Cancel form entry 3
Close Form Event 4
IsLoaded not working 2
Can't cancel command button close. 2
Cannot trap 2501 error 5
Close form without saving 13
Add extra code to close form? 7
Access Form Refresh 1

Top