Run-time error on acCmdDeleteRecord

G

glnbnz

All I want to do is close a form without saving anything in the text boxes.
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
I figured this would not be so hard to accomplish. The true side works
fine. But if something is in the box I receive a run-time error and "The
command or action 'DeleteRecord' isn't available now." I don't know
why....could someone please help me.

Thank you
 
K

Klatuu

That is because if you are in the process of adding a new record, it really
isn't a record in the table yet. You don't delete it, you Undo it.

Else
Me.UnDo
Call OpenControl
 
G

glnbnz

Thank you That did it

Klatuu said:
That is because if you are in the process of adding a new record, it really
isn't a record in the table yet. You don't delete it, you Undo it.

Else
Me.UnDo
Call OpenControl
 

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