non-modifiable fields after entry?

L

Lori

I am using Access 97 and have created a form based on a
single table. Is it possible to lock fields after initial
entry. I have four fields that once populated in the
form, I need to make read-only. On the same note, is it
possible to create a checkbox field, that once checked, it
makes the other 4 fields locked into view only?

Example: Policy #, Date Received, and Assigned Person
are three fields that once entered, I want to make read
only. Can I have a Completed checkbox, that once this is
checked, it makes those fields locked?

How can I do this? Thanks a lot! Lori
 
T

Tony C

Add the following code to the Form "On Current"
Procedure: -

'Unlocks the controlled fields
me.Policy.locked=false:me.dateDateReceived.locked=false:me.
AssignedPerson.locked=false
'locks the controlled fields if record is completed
if me.completed = -1 then
me.Policy.locked=true
me.dateDateReceived.locked=true
me.AssignedPerson.locked=true
exit sub
end if
'Locks the controlled fields if the controlled fields have
content
if me.Policy <> "" then me.Policy.locked=true
if me.DateReceived <> "" then me.DateReceived.locked=true
if me.AssignedPerson <> "" then
me.AssignedPerson.locked=true

NOTE

I've re-named the controls in the above example to remove
spaces, this is because VB does not work very well with
spaces in object names!!

The above code will always be applied whenever a user
accesses another record, it will not lock the content
after it is changed until a user accesses another record.
This method allows a user to change the data before they
access another record.

HTH


Tony C.
 

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