Edit and Delete options

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form that has a delete button which deletes a record. I don't want
user to be able to edit the records but delete as needed. When I change the
edit option on the form to no, The delete option no longer works. Below is
the delete button code.

Private Sub delbutton_Click()
On Error GoTo Err_delbutton_Click


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

Exit_delbutton_Click:
Exit Sub

Err_delbutton_Click:
MsgBox Err.Description
Resume Exit_delbutton_Click

End Sub

How can if fix this issue?
 
Hi, McCloud.

See Help on the AllowEdits property. If set to No, it prevents a record
from being deleted regardless of the AllowDeletions setting. But you can
toggle it off, and then back on:

Me.AllowEdits = True
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
Me.AllowEdits = False

HTH
Sprinks
 
Thanks that worked

Sprinks said:
Hi, McCloud.

See Help on the AllowEdits property. If set to No, it prevents a record
from being deleted regardless of the AllowDeletions setting. But you can
toggle it off, and then back on:

Me.AllowEdits = True
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
Me.AllowEdits = False

HTH
Sprinks
 
Back
Top