Lock / Unlock only one field on form

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

Guest

Hello,
I have a form with only one field that needs to be locked, but with the
option to edit if necessary. The problem arises when users are maneuvering
thru database and don't pay attention to where they are and this particular
field, which is the first entry field on form, sometimes gets deleted. I
want to lock this field when it's not a new record and have a command button
they have to click on to change the data when necessary.

This is the code I have used for the command button

Me.CustomerNameCombo.Locked = False
Me.CustomerNameCombo.SetFocus

I've read other posts and have tried various coding and can't get it to work
properly. Either it won't lock when it is supposed to or locks when I need
to enter data for new records.

I know there is a solution and any help is greatly appreciated!
Thanks in advance,
Pam
 
PHisaw,
Try this...

Private Sub Form_Current()
If Me.NewRecord = False Then
Me.CustomerNameCombo.Locked = True
Else
Me.CustomerNameCombo.Locked = False
End If
End Sub
 
Al,

Thanks for the quick response. It worked just as I wanted. I had something
similar but on Form Load.
Thanks for your help,
Pam
 
Back
Top