after delete record, new record

G

Guest

I would like to be able to click the delete button on my form (which has a
subform)and have it delete the record and then have the form set to New
Record.
Below is my code but it bombs on moving to a new record New record
msg... the command or action RecordsGoToNew isn't available now.

Can you help??


Private Sub btnDeleteCI_Click()
On Error GoTo Err_btnDeleteCI_Click

Me.AllowEdits = True
Forms!f2CustImpactsEdit.Form!f2CustImpactsEditDetails.Form.AllowEdits = True
Me.AllowDeletions = True
Forms!f2CustImpactsEdit.Form!f2CustImpactsEditDetails.Form.AllowDeletions =
True
Me.AllowAdditions = True
Forms!f2CustImpactsEdit.Form!f2CustImpactsEditDetails.Form.AllowAdditions =
True

Msg = "Are you sure you want to delete this Customer Impact? This will
delete the entire Customer Impact record."
Ans = MsgBox(Msg, vbYesNo)
If Ans = vbNo Then
MsgBox "The Customer Impact has NOT been deleted."
Exit Sub
Else
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
MsgBox "The Customer Impact has been deleted."
End If

Me.Refresh
Forms!f2CustImpactsEdit.Form!f2CustImpactsEditDetails.Form.Refresh
DoCmd.RunCommand acCmdRecordsGoToNew
 
G

Guest

Hi Deb

You don't need the refresh and also move the new record line up

Msg = "Are you sure you want to delete this Customer Impact? This will
delete the entire Customer Impact record."
Ans = MsgBox(Msg, vbYesNo)
If Ans = vbNo Then
MsgBox "The Customer Impact has NOT been deleted."
Exit Sub
Else
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
DoCmd.GoToRecord , , acNewRec
End If
 

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