Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

locking all fields on a form based on a field 1

Status
Not open for further replies.

nexus

Programmer
Jun 16, 1999
28
0
0
CA
I was wondering if there was some easy way to lock all fields on a form based on the value of one field. Thanks!
 
nexus,<br>
You can do the following, on whichever event you want to track the field, ie, Open, AfterUpdate of that field, etc.<br>
If me.checkedfield = somevalue then<br>
For i = 0 to me.fields.count -1<br>
If Typeof me(i) is TextBox Then<br>
me(i).locked = true 'Or Enabled = false, if you want that effect)<br>
ElseIf Typeof Me(i) is CommandButton then<br>
me(i).enabled = false<br>
End If<br>
next I<br>
Else<br>
For i = 0 to me.fields.count -1<br>
If Typeof me(i) is TextBox Then<br>
me(i).locked = false <br>
ElseId Me(i) is CommandButton then<br>
me(i).enabled = true<br>
End If<br>
next I<br>
End if<br>
<br>
Then, if you have fields you always need enabled, such as an Exit button, then enable them at the bottom of the code, regardless of the fields value<br>
--Jim
 
Can you just set the form's allowedits property to false, if value = xx?? Put code in the afterupdate property of the field you're basing the decision on or in the onopen propery of the form depending on your timing. Check out the allowedits property example in help if you want to go this route--- <p>jgarnick<br><a href=mailto:jgarnick@aol.com>jgarnick@aol.com</a><br><a href= > </a><br>
 
Don't forget you may someday need to change the control that indicates the &quot;editability&quot; of the record. You might want to leave that one field editable.
 
If you want to keep the fields locked when users are just browsing the records, place the code as well into form's OnCurrent property. It runs every time when user moves between records. OnOpen or OnLoad does the trick only once for the first record.<br>
<br>
Al
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top