Results 1 to 5 of 5
  1. #1
    Sue22's Avatar
    Sue22 is offline Novice
    Windows 8 Access 2013
    Join Date
    Mar 2015
    Posts
    15

    Preventing accidental changes to one field on a form

    Hi I have a form which users will use to both create new records in a table but to also update existing records.

    There is one field on the form which once it is created they should not be making any changes to. How do I stop them doing this?

    I tried adding a macro (on Change) that popped up a warning box saying they were not permitted to change this field and then undid their change but it does this both to existing records and also when I try to create a new record. I only want to do it when they try to change an existing record not when the try to add a new record (the value entered in this field is the primary key)



    Thanks in anticipation

  2. #2
    lfpm062010 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Location
    US
    Posts
    415
    Go to form design, click on the field that you don't want anyone make any changes. Right click and select property. Find "Enabled" and/or "Locked" Change "Enabled" to "No" and/or changed "Locked" to "Yes".

  3. #3
    Sue22's Avatar
    Sue22 is offline Novice
    Windows 8 Access 2013
    Join Date
    Mar 2015
    Posts
    15
    This doesn't work because if you do this you can't create a new record! The field is the primary key and has to be entered by the user when they first create the record I just don't want anyone to change it later on by accident!

  4. #4
    NTC is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2009
    Posts
    2,392
    In the OnCurrent event of the form property itself one would put:
    If IsNull(me.FieldName) then
    Me.FieldName.Unlock
    Else
    Me.FieldName.Lock
    End If

  5. #5
    Sue22's Avatar
    Sue22 is offline Novice
    Windows 8 Access 2013
    Join Date
    Mar 2015
    Posts
    15
    Thanks that's really helpful

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

Similar Threads

  1. Replies: 7
    Last Post: 12-09-2014, 03:06 PM
  2. Replies: 9
    Last Post: 10-10-2013, 06:24 PM
  3. Replies: 2
    Last Post: 02-28-2013, 10:06 AM
  4. Preventing Form Close
    By ramhanuman in forum Forms
    Replies: 1
    Last Post: 05-02-2012, 03:43 PM
  5. Replies: 2
    Last Post: 02-29-2012, 12:51 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