Close a form with dbCmd

  • Thread starter Thread starter Jack Witt
  • Start date Start date
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
 
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.
 
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.
 
Back
Top