Solved

Lock all text boxes on a form

Posted on 2004-04-05
4
318 Views
Last Modified: 2012-06-22
I have a form that has several text boxes on it. I wish to LOCK all the text boxes until a certain condition s met.  Is there a way to LOCK all text fields with having to lock each one by its property screen?

The boxes are all named:   textFields(1)    textFields(2)   textFields(3),     etc....

Thanks

Charlie

0
Comment
Question by:CMHamrick
  • 2
4 Comments
 
LVL 17

Expert Comment

by:zzzzzooc
ID: 10760189
Private Sub Form_Load()
    'Sets .Locked=True for all TextBoxes on Form1
    Dim ctrlText As TextBox
    For Each ctrlText In Me.Controls
        ctrlText.Locked = True
    Next ctrlText
End Sub
0
 
LVL 19

Expert Comment

by:Shauli
ID: 10760243
'use the KeyPress event.

Private Sub textFields_KeyPress(Index As Integer, KeyAscii As Integer)
If "your condition" = "criteria" Then
    textFields(Index).Locked = True
End If
End Sub

S
0
 

Author Comment

by:CMHamrick
ID: 10760252
That did not work... error on:       ctrlText     ????
0
 
LVL 17

Accepted Solution

by:
zzzzzooc earned 500 total points
ID: 10760267
What's the error? It loops through the object collection for TextBoxes and sets the Locked=True for each one.

Alternate:

Private Sub Form_Load()
    Dim objTmp As Object
    For Each objTmp In Me.Controls
        If TypeOf objTmp Is TextBox Then
            objTmp.Locked = True
        End If
    Next objTmp
End Sub
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now