Continuous form with field.enable=false, but want user able to add

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

can I have a continuous form field disabled so the user can't change
existing data, but allow them to enter a new record at the bottom of the
continuous grid. The was it is, if I disable the field, they can't enter it
on the new record either.
 
Mike said:
can I have a continuous form field disabled so the user can't change
existing data, but allow them to enter a new record at the bottom of
the continuous grid. The was it is, if I disable the field, they
can't enter it on the new record either.

If you want to prevent any editing of existing records (any controls),
set the form's AllowEdits property to False. If you need to disable
just this field, use the form's Current event and NewRecord property to
determine the control's status. For example (air code):

'----- start of example (air) code -----
Private Sub Form_Current()

With Me!MyControlName
If Me.NewRecord Then
.Enabled = True
.Locked = False
Else
.Enabled = False
.Locked = True
End If
End With

End Sub
'----- end of example code -----
 
Thanks, that worked.

Dirk Goldgar said:
If you want to prevent any editing of existing records (any controls),
set the form's AllowEdits property to False. If you need to disable
just this field, use the form's Current event and NewRecord property to
determine the control's status. For example (air code):

'----- start of example (air) code -----
Private Sub Form_Current()

With Me!MyControlName
If Me.NewRecord Then
.Enabled = True
.Locked = False
Else
.Enabled = False
.Locked = True
End If
End With

End Sub
'----- end of example code -----

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 
Back
Top