View Single Post
  #4  
Old January 9th, 2008, 04:47 PM posted to microsoft.public.access.forms
Klatuu
external usenet poster
 
Posts: 7,074
Default locking a field in a form

No, it needs to be the actual name of the control.
--
Dave Hargis, Microsoft Access MVP


"Debbie S." wrote:

Thank you for your quick response. I just tried this, and I got an error
message:

Compile Error: Method or data member not found

It was highlighting the name of the control I had substituted for
".txtsomecontrol" in your code. I substitued as follows: .txtmycontrolnamehere

Is that the correct way to do it?

Thanks again,
Debbie

"Klatuu" wrote:

Yes, use the form's Current event:

With Me
If .NewRecord Then
.txtSomeControl.Enabled = True
.txtSomeControl.Locked = False
ElseIf IsNull(.txtSomeControl) Then
.txtSomeControl.Enabled = True
.txtSomeControl.Locked = False
Else
.txtSomeControl.Enabled = False
.txtSomeControl.Locked = True
End If
End With

It will unlock the control for new records and for existing records where no
entry has been made and Lock it for exiting records where a value exits.
--
Dave Hargis, Microsoft Access MVP


"Debbie S." wrote:

Hello,

I want to be able to lock a field but still allow the user to enter NEW data
into the field in the form. (In other words, allow users to enter new data
into a particular field of a form but not change existing data in that
field). If I lock the field in the properties sheet, the data can't be
edited, which is good, but you can't enter new data either, which defeats the
purpose of the form. Is there a way to do this?

Thanks,
Debbie