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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Lock a form based on text box value

Status
Not open for further replies.

Dandy55

Technical User
Jun 21, 2001
4
CA
I have a form which contains a subform. In the main forms on_current event, if the value of a specific text box on the main form is equal to a certain value, I set the allowedits property to false. What is happening is when you go to a form where the text box meets the criteria to set the allowedits to false, you can still edit all of the fields. But if you click on the subform, and then back on the main form, you can not make any edits. What am I doing wrong, or how can I make this work properly?
 
Hallo,

To lock all controls on a form use something like:
sub txtLock_AfterUpdate()
Dim ctrControl As Control
If Me!txtLock="Locked" then
For Each ctrControl In Me.Controls
With ctrControl
If .name <> &quot;txtLock&quot; Then
.Locked = False
End If
End With
Next ctrControl
end if

I could have used
.Locked = (.name = &quot;txtLock&quot;)
instead of the centre If statement, but then it becomes harder to add other conditions if you want to not make all other controls locked.
Anyway, you get the idea. You can use .ControlType to determine, er, the type of the control. That may be useful.

- Frink

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top