restricting form fields

G

Guest

When a new record is created on my form, all fields are editable. However,
when a record is revisited, I want to restrict only a few of the fields from
being edited. This will ensure a user doesn't accidentally overwrite an
existing record with a new entry, but still allows them some editing
flexibility. Please let me know. Thanks!
 
G

Guest

You can use the NewRecord property to control whether a control is editable.
Exactly how you do it depends on how you want your form to behave. That is
because of the behaviour and appearance of the Enabled and Locked properties.
Basically, you will want to use the form's Current event:

'Locks controls for existing records and Unlocks for new records
Me.SomeControl.Locked = Not Me.NewRecord
Me.AnotherControl.Loced = Not Me.NewRecord
 
A

Allen Browne

Set the Locked property of the controls that should not be edited. Use the
Current event of the form.

If the form's NewRecord is false, set the Enabled property of each relevant
control to No.

There is sample code in this article that lets you specify which controls
not to lock, by listing them as extra arguments. The code also handles
subforms, but it won't matter if you have no subforms. See:
Locking bound controls on a form and subforms
at:
http://allenbrowne.com/ser-56.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top