DeleteRecord

G

glnbnz

I am having a problem with closing a form without saving a record.
If IsNull(txtUserName) Then
DoCmd.Close acForm, "Edit - Add new user", acSaveNo
Call OpenControl
Else
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdDeleteRecord
DoCmd.Close acForm, "Edit - Add new user", acSaveNo
Call OpenControl
End If
When I run this code the true side is fine. On the false side I receive an
runtime error and "The command 'DeleteRecord' isn't available now" I don't
know why....could someone help me on this.
Thank You
 
A

Allen Browne

Not sure exactly what you are doing, but if the idea is to close the form
without saving the any edits that are in progress, this should work:


If Me.Dirty Then
Me.Undo
End If
DoCmd.Close acForm, Me.Name
 

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

Top