|
-
Dec 24th, 2005, 12:32 AM
#1
Thread Starter
Lively Member
How to Lock Textboxes on Form?
hi there,
i know the command to Lock Editing in Textboxes that is:
Text1.text.locked = true
I have more than 60 texboxes on a Form, it is bit head-ech to write above said command for each textbox.
Is there any method to lock all the textbox on form with single or 2 line cod?
plz help
-
Dec 24th, 2005, 01:08 AM
#2
Re: How to Lock Textboxes on Form?
Iterate through the controls collection to find all textboxes
VB Code:
'Put in a module so it can be called by any form.
Public Sub LockUnlockTextBoxes(Form as Form, Optional ByVal Locked as boolean = True )
Dim ctl as Control
For each ctl in Form.Controls
If TypeOf ctl is TextBox Then
ctl.Locked = Locked
End If
Next
End Sub
'sample calls from command buttons on a form
Private Sub cmdLockEm_Click()
LockUnlockTextBoxes Me
End Sub
Private Sub cmdUnLockEm_Click()
LockUnlockTextBoxes Me, False
End Sub
-
Dec 24th, 2005, 02:40 AM
#3
Thread Starter
Lively Member
Re: How to Lock Textboxes on Form?
Mr. Brucevde,
Your code for lock texbox is working (thanx)
But when i try to unlock them, it wont work... with error message (sub or function not defined)
my code is here
---------------------------------
Private Sub unlock_Click()
Dim Password As String
Dim InputPassword As String
Password = "code"
Do
InputPassword = inputbox("Contact Administrator")
If InputPassword = Password Then
LockUnlockTextBoxes Me, False
txtkrun.SetFocus
Else
MsgBox "ACCESS DENIED", vbCritical, "ERROR"
End If
End Sub
-
Dec 24th, 2005, 07:30 AM
#4
Re: How to Lock Textboxes on Form?
That means you have a sub or a function that you are calling that isn't defined.
It either doesn't exist in your project, or you misspelled the name when you called it. Which one is the error pointing to?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|