Edit Button

  • Thread starter Thread starter John
  • Start date Start date
J

John

I previously asked a question on how to have a form that
can't be edited unless you click an 'edit' button. I got
this reply and can't seem to get it to work. I am very
new at this and am clueless in a lot of regards. I set
the form's AllowEdits property to No. But when I went
into the code builder for the event procedure for the
command button and pasted in the code it didn't work. I
know that it can't be a straight copy, but am unsure how
to input this code in as an event procedure. I am also
unsure what the 'Me' actually means. any help would be
greatly appreciated....Thanks...

Set the form's AllowEdits property to No.

Set the command button's Click event procedure to
something like this:

Private Sub cmdToggleEdit_Click()
If Me.Dirty Then 'Save any changes first.
Me.Dirty = False
End If
Me.AllowEdits = Not Me.AllowEdits
Me.cmdToggleEdit.Caption = IIf
(Me.AllowEdits, "&Lock", "Un&lock")
End Sub
 
Hi John
Set the On Click property of your command button to:
[Event Procedure]

Then click the Build button (...) beside it.
Access will open a code window, and it will contain:
Private Sub cmdToggleEdit_Click()
End Sub
(Note the "cmdToggleEdit" bit will be whatever your button is named.)

Paste the code between those lines, so it looks like the sample you posted.
 
Back
Top