Don't Allow Editing if a field is populated

S

Steve D

I am trying to lcok the record from being edited if one field is populated.
To make it a little more involved I want to be able to edit only that one
field. For example if the date_closed field has a date in it the record
should not be editable except for the ability to remove the date_closed value
which would then open the record for editing. Here is what I tried for the
basic portion but it does not seem to work. Any help would be greatly
appreciated.

Private Sub date_closed_AfterUpdate()
If IsNull(date_closed) Then
Form.AllowEdits = True
Else
Form.AllowEdits = False
End If
End Sub
 
R

Rick B

First, you need to have this procedure run in the event you specified and
ALSO in the "current" event. That way the field will be checked as you page
from one record to another.

Second, you are setting the form's allow edits. You specifically told us
you want to lock all the controls except one. Don't lock the record, lock
the controls.

Me.SomeControlName.Locked = True
Me.SomeOtherControlName.Locked = True
etc.
Else
Me.SomeControlName.Locked = False
Me.SomeOtherControlName.Locked = False
etc.
 
Top