Re: How do I exit a form without saving the entered data in a tabl
- From: Klatuu <Klatuu@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 14 Sep 2006 06:01:02 -0700
You are correct. The other solutions offered are making it a lot harder than
it has to be.
If there is any code in VBA that drives me up the wall it is the DoMenuItem.
It is clumsy and impossible to read. It is also one of the features
Microsoft included in Access for those who are not really programmers.
Macros fall into that category as well.
"BruceM" wrote:
I would think that.
Me.Undo
is all you would need (other than error handling) in the Click event for the
Cancel button.
"D' Polygon" <rjacobp@xxxxxxxxx> wrote in message
news:1158201657.802584.150170@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
in your cancel button just add
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
This will undo the recent record addition to the table
Hope this helps.
james_keegan via AccessMonster.com wrote:
Sharon Greene wrote:
I created a form that takes data entered by users and saves it to a
table. I
added a "Cancel" button. If a user begins to enter information in the
form,
but decides not so save it to the table, I want this button to close the
form
and not save the entered data to the table. Are there any suggestions?
For 'canceling' a new record, you'll need the macro to build a delete
query
that deletes the record with the id number that you grab from the control
before you close the form.
So something like this (off top of head, no guarantees!):
drec=me.ctlID
sstring="delete * from tblMyTable where [id]= " & drec
docmd.closeform "MyForm"
docmd.runsql sstring
That way, assuming that drec=57, the string ends up looking like "delete
*
from tblMyTable where [id]=57", which is what we want. (for future use,
remember that if [field] is text, then the WHERE clause has to have quote
delimiters, like [workername]='Smith', and if [field] is a date it has to
have # delimiters, like [StartDate]=#5/21/06#)
Hope that helps
JK
--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-forms/200609/1
- References:
- Re: How do I exit a form without saving the entered data in a table?
- From: james_keegan via AccessMonster.com
- Re: How do I exit a form without saving the entered data in a table?
- From: D' Polygon
- Re: How do I exit a form without saving the entered data in a table?
- From: BruceM
- Re: How do I exit a form without saving the entered data in a table?
- Prev by Date: Re: Checking if form is hidden
- Next by Date: Option Buttons - 3 options
- Previous by thread: Re: How do I exit a form without saving the entered data in a table?
- Next by thread: Re: How do I exit a form without saving the entered data in a table?
- Index(es):