I have a form that is set to allow edits no to prevent accidential changes to data. I am trying to write a command button the will allow a record to be changed and when saved set the allow edits back to no. I am very new at this and need help.
Hi. Try to use this codes! Hope it will help you...
Code:
Private Sub cmdsave_Click()
On Error Resume Next
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Me.AllowEdits = False
End Sub
Private Sub CmdEdit_Click()
On Error Resume Next
Me.AllowEdits = True
End Sub
DoMenuItem is an old command and should be avoided if possible. There's an equivalent action in DoCmd.RunCommand. Also, the OP wasn't asking for a save button
I prefer to toggle on / off the .enabled properties of each control on the form via a loop (excluding the ones which I don't want locked like search windows, command buttons, etc).
That way the fields are greyed out for a visual clue to the uneditable nature of the data and the data cannot be edited as the field isn't enabled.