Results 1 to 3 of 3
  1. #1
    Xterra14s is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    May 2016
    Posts
    32

    Edit button on form?

    I have a form that needs to display patient information that is locked to edits to keep anything from being changed in this section by accident. If the end user wants to update the patient phone number or address I want an edit button that will unlock the subform. Any way to do this? I tried the following with no luck



    Open the form in design view.
    Activate the Event tab of the Property Sheet.
    Select [Event Procedure] from the dropdown in the On Current event.
    Click the builder buttons ... to the right of the dropdown arrow.
    Make the code look like this:

    Private Sub Form_Current()
    Me.AllowEdits = Not Me.NewRecord
    End Sub


    This will disable editing when the user loads an existing record, New records can still be created and edited.
    Switch back to the form in Access.
    Place a command button on the form. Make sure that the command button is selected.
    Activate the Format tab of the Property Sheet and set the Caption property to Edit Record or whatever you prefer.
    Activate the Other tab of the Property Sheet and set the Name property to cmdEdit.
    Activate the Event tab of the Property Sheet.
    Select [Event Procedure] from the On Click event, then click the builder buttons ...
    Make the code look like this:



    Private Sub cmdEdit_Click()
    Me.AllowEdits = True
    End Sub

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    You do realize you will get a Current Event *every* time you switch to a different record, right?

  3. #3
    Micron is offline Very Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    Consider setting the Enabled property of the controls to False on open and True on button click. You only mentioned a couple of controls, so maybe you'd need a more robust procedure if there are a lot of them that need to be cycled. For this I'd use a procedure that reads a tag for those controls (see property sheet Tag property) and cycle through the form controls collection. You probably would want to reverse the enabled property after some sort of event, but you didn't indicate that was desired.

    Usually, locking controls keeps lower level users from editing certain fields, but I don't see any indicator that security is coming into play, so does it make sense to introduce an unlocking step if just anyone can invoke it?
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Search form with a Edit Button
    By gebmiller1984 in forum Forms
    Replies: 5
    Last Post: 02-14-2015, 11:54 AM
  2. Edit Button for Locked Form?
    By tanyalee123 in forum Forms
    Replies: 6
    Last Post: 11-21-2013, 02:04 PM
  3. Replies: 5
    Last Post: 11-06-2013, 02:49 PM
  4. Replies: 1
    Last Post: 05-31-2013, 08:53 AM
  5. Edit button in a form?
    By Aleksandra in forum Forms
    Replies: 8
    Last Post: 04-27-2012, 12:42 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums