Locked Fields

  • Thread starter Thread starter Aurora
  • Start date Start date
A

Aurora

I am using Access 2000
I asked this question last Friday, but can not find my
question now. So here I go again. I want to create a
form in which I have two fields - "EmpID" and "Name". I
made these fields "look-up" based on a table with the two
same fields. Can I have the "Name" field automatically
entered based on the "EmpID" entered? If so how can I do
this?

I also want to lock the "EmpID" field once something has
been entered. But If I lock it now, I can not enter any
EmpID into the field. Can someone please help me with
this?

Aurora
 
here is the answer I posted Friday....
----------------------------------------------------------------------------
--------
If it were me, I'd add a "find number" field to the header section of my
form. I'd put code in the field's on exit event to find the matching record
and pull it to the form. You could then simply lock the employee number
field in the actual detail section of the form.

If you want to do it the way you have it, you would have to create code in
the "current" event to test and see if a value exists. If so, lock the
field, if not, unlock it. There is also a test you can do that would simply
say, if this is a new record" then unlock the field.

To populate the name, you'd have to include the name as one of the columns
in your drop-down and put it in the name field on your form.

Use option one if you want the person to pull up an existing record from the
table and make changes to it.

Use option two if you are building related records and you want to prefill
some of the data so the links will be correct.

Post back if you have questions, but let us know which of these two options
you are using changing an existing record, or adding related data in another
table.

--
Rick B



Aurora said:
I am using Access 2000

1. I created a form with a field for "EmpID". I made
this field a drop down list so employees only have to
click on a button and pick out their ID#. But I want to
lock this field so that once the field has data and the
record is saved it can not be changed. I tried locking
the field, but then I can not even enter data into a blank
field. Can't change the field (which is what I want), but
can not enter a new record either. What am I doing wrong?

2. Is there a way to add a "name" field based on
the "EmpID". Meaning someone picks out their ID#, and the
name field automatically puts in the correct name?

Aurora
 
See the FormsCoding discussion (2 Questions, 4/29/2005) as this is where you
originally posted and Rick G. already replied to that question.

Jim
 
Back
Top