Results 1 to 6 of 6
  1. #1
    angie is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2013
    Posts
    232

    Save record so no changes can be made

    Hi I have a form that we enter data into and once we have it correct I want it so no changes can be made to the records


    I have a combo box with a value of "pending" and " approved" I want to prevent changes to this record only if "approved" is selected.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    In the forms ON CURRENT event,
    lock the form unless the cbobox = Approved
    Code:
    sub form_OnCurrent()
      me.locked = not (cbobox = 'Approved')
    end sub

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722

  4. #4
    angie is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2013
    Posts
    232
    Quote Originally Posted by ranman256 View Post
    In the forms ON CURRENT event,
    lock the form unless the cbobox = Approved
    Code:
    sub form_OnCurrent()
      me.locked = not (cbobox = 'Approved')
    end sub

    I want to lock the record not the form. I tried the above but nothing happens
    I used the followins

    me.locked = not (status = 'pending')

    (status is the combo box and I want it to lock the record if the results is approved.
    thanks angie

  5. #5
    Micron is online now Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,793
    If you want to do this on a record by record basis (and presumably you want users to be able to cycle through records on the form) then locking the form by any means won't do it. You'll have to examine the parameter (status?) in a suitable event and disable or lock the form controls. The form OnCurrent event should work as long as you haven't done anything design-wise to make it unsuitable.

    The way I like to do this is add a control tag property value and cycle through the form controls looking for that value. If found, disable it according to the parameter value. Another way is to have a flag field (yes/no type) in the table to flag locked records. Using the same approach, you'd lock or disable the required controls based on the flag. This would only provide more flexibility, such that you would not have to have all records with a given status affected the same way. Using the following should disable every text or combo box regardless of any tag property, but it should provide a clue as to what I'm suggesting
    Code:
    Dim ctl As Control
    
    If Me.Status = "approved" Then
      For each ctl in Me.Controls
        If ctl.ControlType = acTextBox Or ctl.ControlType = acComboBox Then
          ctl.Disabled = True
        End If
      Next
    End If
    It's entirely from memory, which is not always serving well these days.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  6. #6
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    The Locked property applies to individual Controls, not to the Form, itself, as a whole.

    To do this you can use

    Code:
    Private Sub Form_Current()
     If Me.Status = "Approved" Then
      Me.AllowEdits = False
     Else
      Me.AllowEdits = True
     End If
    End Sub

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

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

Similar Threads

  1. Can't save database objects when changes made
    By stanley721 in forum Access
    Replies: 8
    Last Post: 10-12-2015, 08:51 PM
  2. Replies: 5
    Last Post: 09-23-2013, 08:37 AM
  3. Replies: 3
    Last Post: 10-08-2012, 08:40 AM
  4. Replies: 8
    Last Post: 09-27-2012, 11:12 AM
  5. Changes made in form are not save sporadically
    By struggling in forum Forms
    Replies: 2
    Last Post: 05-27-2010, 03: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