vbams-accessidentity-columnsubform

Access allow addings but no edits in certain columns in a subform


I got question if it is possible to allow addings but no edits in certain columns in a subform? I can do this for the whole form, but i can't do this for single columns.

For example:

enter image description here

I want to be able to allow edits in [Type], and in [Omschrijving] I only want to allow adds and no edits.

I can lock certain columns. For example:

Private Sub Form_Load()
    Me.Omschrijving.Locked = True
End Sub 

But then I'm not able to make any adds. Is there another way to make this possible?


Solution

  • Only lock if not a new record. Use form Current event instead of Load.

    If Not Me.NewRecord Then
       Me.Omschrijving.Locked = True
    End If
    

    Might use Enabled property instead so control shows as unavailable for edit, in which case could use Conditional Formatting for textboxes and comboboxes instead of VBA. Rule something like:
    Expression is: Not Forms!formname.NewRecord
    Then click the Enable/Disable button so if this condition is met, control is disabled.