in Access 97, can particular fields (not all) on a form be locked so that the data (once entered) cannot be changed.
I tried to lock the field, but upon locking you can't even enter NEW data.
in Access 97, can particular fields (not all) on a form be locked so that the data (once entered) cannot be changed.
I tried to lock the field, but upon locking you can't even enter NEW data.
I have never used ac97 so this may not apply. In acXP and > there is no way to do this at the table level but you could do it in a Form. Simply put code in the Current Event of the Form to disable (Me.YourControlName.Enable = False) the controls you want when Me.NewRecord is False.
if you're interested in the theory of this, and how it relates to online technology that's similar, you might consider using flags or something to identify your records. for instance, a small script that runs once new records are entered to manipulate a boolean field, one way or the other, which indicates the fields permanently locked.
Private Sub Form_Current()
If Me.NewRecord = False Then
Me.Property_Address.Enabled = False
End Sub
This code does lock the Property Address field but it is also locked on a new record. Don't I need an ELSE line?
Yes you do...and an End If.
Code:Private Sub Form_Current() If Me.NewRecord = False Then Me.Property_Address.Enabled = False Else Me.Property_Address.Enabled = True End If End Sub
A shorter code would be:
Code:Private Sub Form_Current() Me.Property_Address.Enabled = Me.NewRecord End Sub
Got all 6 of my fields working as planned. One last thing. When I open the form now I am on the first of the 2 fields that are able to be edited as it should be. However, on a new record how do I get the curser to be in the first field again and continue in the correct tab order?
Since the Event happens when you just get to the new record, the controls will not be enabled yet. As the last line of your event, set the focus to the control you want.
Me.ControlName.SetFocus
...should do it, using *your* ControlName of course.
That's it!! Thanks again.
I will mark this post as resolved.
Excellent! Glad we could help.