Search code examples
ms-accesslinked-tablesms-access-forms

MS Access form - lock columns from editing


Is it possible to lock specific columns from editing in an Access form ?

The problem is that I have a linked table in a form that shows information and users can update it. Now it turned out that there are some columns that need to be displayed to make the right decision, but I don't want them to edit these columns.


Solution

  • Use Form_BeforeUpdate event on your form.

    Private Sub Form_BeforeUpdate(Cancel As Integer)
        If Me.Field <> Me.Field.OldValue Then
           Cancel = True
        End If
    End Sub
    

    Me.Field is the column which user cannot change here. You can apply any logic/validation in this block.

    Download Sample File - It has form frmEmployee which doesn't allow to change Employee name