Reputation: 509
In my Ms Access form - I have a few locked fields. So, that users won't be able to change existing information. But they might still needed to add a new records into the Form.
Is it possible to be able to add a new records, without changing or removing an existing ones?
Thanks, as always!
Upvotes: 0
Views: 598
Reputation: 654
If you want to be able to add new records and keep some form fields locked, you have to set the Locked property on the data tab only for those fields. You can do that in design mode, or you can do it via VBA code on form load.
See https://access-programmers.co.uk/forums/showthread.php?t=180359 for examples.
Upvotes: 2
Reputation: 1093
Define an On Current event on form level. Like
Private Sub Form_Current()
If Me.NewRecord Then
Me.txtField1.Enabled = True
Me.txtField2.Enabled = True
Else
Me.txtField1.Enabled = False
Me.txtField2.Enabled = False
End If
End Sub
Replace txtField1 and txtField2 with the names of your form fields.
Upvotes: 2
Reputation: 1077
Your last comment explains things a little better, I believe what you're after is possible (assuming I have the right idea). There are many ways to go about doing what you suggest, but without more specifics it becomes harder to guide you. That being said, terminology you're looking for in this question is something along the lines of "Lock fields when the Current Record is not a New Record".
This may partially solve your problem, you can probably figure it out from there:
Within the form itself, go to the Property Sheet
and Select Data
. Within the Data Tab
change Allow Edits
to No
.
This will allow only New Records to be added to your table through your form, which appears to be your end-goal.
(Of course, you'll need to remove any locks on the text boxes that still remain to add any new records)
Upvotes: 1