Deleting a Record

mrsgwen

Registered User.
Local time
Today, 09:39
Joined
Dec 9, 2008
Messages
26
:confused:i have a form that has a add record, delete record and a close button.
When the form is opened it is on the first record, the user can navigate to the record that needs to be deleted using the built in navigation buttons. Once they find the record to be deleted they should be able to hit the delete button and the record is deleted.

here is my code: (this was created using the wizzard, which I have used in many other applications)

Private Sub cmdDelete_Click()
On Error GoTo Err_cmdDelete_Click

DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

Exit_cmdDelete_Click:
Exit Sub
Err_cmdDelete_Click:
MsgBox Err.Description
Resume Exit_cmdDelete_Click

End Sub
 
I may be missing something, but what is the description of the problem?

By the way, I don't think you can reference menu bars anymore in Access 2007.

SHADOW
 
the problem is that when the user click the delete button it gives an error "DoMenuItem action was cancelled"
 
Also, if I add a record using a "Add Record" button and then go and use the Delete button to delete that same record - it works just fine. But if I navigate to a previous added record then the delete button doesn't work.
 
oh btw here is my new code: (but it's still not working)

Private Sub cmdDelete_Click()
On Error GoTo Err_cmdDelete_Click
If MsgBox("Are you sure you want to delete this record?", vbYesNo, "Confirm Delete") = vbYes Then
DoCmd.SetWarnings False
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdDeleteRecord
DoCmd.SetWarnings True
End If


Exit_cmdDelete_Click:
Exit Sub

Err_cmdDelete_Click:
MsgBox Err.Description
Resume Exit_cmdDelete_Click
End Sub
 

Users who are viewing this thread

Back
Top Bottom