Edit and Delete options

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?
 
G

Guest

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
 
G

Guest

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
 

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