Delete Record

MrMitch

Registered User.
Local time
Today, 11:09
Joined
Oct 19, 2007
Messages
50
I have a form that has an exit button on it. Is there a code I can write that will delete the current record if one has been started, and if not just close the form?

I tried doing this with just a delete record, then close form macro, however if no data has been inputed to start the record, it causes a problem since it has no record to delete.

Thanks for any help and advise.
 
I have a form that has an exit button on it. Is there a code I can write that will delete the current record if one has been started, and if not just close the form?

I tried doing this with just a delete record, then close form macro, however if no data has been inputed to start the record, it causes a problem since it has no record to delete.

Thanks for any help and advise.

Hey MrMitch,

Behind the "exit button" try putting:Me.Undo and see if you get the results your looking for.

HTH,
Shane
 
Shane,

Thanks for the reply. With the undo command, it doesn't seem like it is deleting the record if it has been started.
 
You could run a delete query

docmd.runsql("DeleteSQLStatement")
 
Shane,

Thanks for the reply. With the undo command, it doesn't seem like it is deleting the record if it has been started.

I know. My thoughts were rather than deleting a new record why not just undo everything and not save it. Maybe I'm misunderstanding what you are doing.

Shane

Copied from Help:
Undo Method


You can use the Undo method to reset a control or form when its value has been changed. For example, you can use the Undo method to clear a change to a record that contains an invalid entry.

Syntax

object.Undo

The Undo method has the following argument.

Argument Description
object A Form object or a Control object.


Remarks

If the Undo method is applied to a form, all changes to the current record are lost. If the Undo method is applied to a control, only the control itself is affected.

This method must be applied before the form or control is updated. You may want to include this method in a form's BeforeUpdate event or in a control's Change event.

The Undo method offers an alternative to using the SendKeys statement to send the value of the ESC key in an event procedure.
 
Thanks for the info Shane. Sorry to say, I am actually gonna scrap this idea, and try something else to solve an issue I was having. I appreciate your help in this matter.
 
Thanks for the info Shane. Sorry to say, I am actually gonna scrap this idea, and try something else to solve an issue I was having. I appreciate your help in this matter.

Your welcome and good luck to trying something else.

Shane
 

Users who are viewing this thread

Back
Top Bottom