after delete record. go to new record

deb

Active Member
Joined
Feb 1, 2003
Messages
400
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
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Are you trying to go to a new record on the main form or the sub form? I would also suggest you use DoCmd.RunCommand acCmdRecordsGoToNew rather than the DoMenuItem. The RunCommand is much easier to follow.
 
Upvote 0
Both main form and sub form. I need it to be ready for a brand new record after the old record is deleted.

Thanks
 
Upvote 0
Are you deleting a record from both the main form or are you deleting a record from the subform? Or, when deleting a record from the main form, all records in the subform are deleted? Can you delete a record from the main form, or from the subform? If deleting a record from the main form, you want to go to a new record on the main form? If you delete a record from the subform, you want to go to a new record on the subform? If you delete a record from the main form, do you want to go to a new record on the subform? If you delete a record from the subform, do you want to go to a record on the main form?

Sorry for all the questions, but without some real specifices here, it is just a guessing game as to what you actually want.
 
Upvote 0

Forum statistics

Threads
1,222,118
Messages
6,164,072
Members
451,870
Latest member
Nikhil excel

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top