Code -> Module

baldeagle

Registered User.
Local time
Today, 12:59
Joined
Nov 9, 2004
Messages
38
Howdy,

I'm still trying to grasp modules and how they work. I have a form where I need to lock and unlock all the fields. Can I do this using a module and the Me.XXX.Locked property? Of should I just cut & paste this code into each form?

-Thanks & Gig'em
 
You can do it at module level.

Public Function unlock_textbox()
Dim ctl As Control
For Each ctl In Screen.ActiveForm
If TypeOf ctl Is TextBox Then
With ctl
.Locked = False
End With
End If
Next

End Function

if you want it applied to all controls remove the 'if ' statement above.

if you don't want it applied to some controls put an 'if' statement after..With ctl...like this

Public Function lock_textbox()
Dim ctl As Control
For Each ctl In Screen.ActiveForm
If TypeOf ctl Is TextBox Then
With ctl
'check if the tag property of the control is set to Not locked
If ctl.Tag <> "Not Locked" Then
.Locked = True
End If
End With
End If
Next

End Function
 

Users who are viewing this thread

Back
Top Bottom