Unlock TextBox

kmrkmj

New member
Local time
Today, 12:34
Joined
Nov 2, 2006
Messages
5
Hello,

I'm using this bit of code to lock my controls on a form

Code:
Private Sub Lock_Controls()

'Locks the controls to prevent editing

    Dim ctrl As Control
    
    For Each ctrl In Me.Controls
      If TypeOf ctrl Is TextBox Then
       ctrl.Locked = True
      
      End If
      
      If TypeOf ctrl Is CheckBox Then
        ctrl.Locked = True
        
      End If
      
      If TypeOf ctrl Is ComboBox Then
        ctrl.Locked = True
        
      End If     
 
    Next

    txt_SearchBox.Enabled = True

End Sub

I have a "Edit" button that will run the opposite code to unlock the controls which works fine. My problem is that I want txt_SearchBox in the header to remain enabled to search the continuous form but it remains locked until I hit the "Edit" button. Any ideas?
 
Me.txt_Searchbox.Enabled = True ?

Or when you process the textbox controls, check it's name and skip if the search box?
 
Hi. Another approach is to use the control's Tag property, You simply tag the ones you want locked and leave the other ones alone (empty).
 
Me.txt_Searchbox.Enabled = True ?

Or when you process the textbox controls, check it's name and skip if the search box?


Yep your question mark made it click for me. I was using enabled instead of lock. Thanks!
 

Users who are viewing this thread

Back
Top Bottom