Question : Control lock Question

I recently created the code in code snippet .....and locks all controls as expected except that it does not disable command buttons with names begining with "btn". How can I tweak it to lock commands buttons with "btn" ?
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
Private Sub LockEm() 
Dim ctr As Control 
    For Each ctr In Me.Controls 
       Select Case ctr.ControlType 
        Case acTextBox, acListBox, acComboBox 
            If g_lAccessID = 6 And (left(ctr.Name, 3) = "txt" Or left(ctr.Name, 3) = "cbo" Or left(ctr.Name, 3) = "chk" Or left(ctr.Name, 3) = "l_") Then 
                    ctr.Locked = True 
            Else 
                    ctr.Locked = False 
            If g_lAccessID = 6 And left(ctr.Name, 3) = "btn" Then '<---- This part does not work
                    ctr.Enabled = False 
            Else 
                    ctr.Enabled = True 
                End If 
             End If 
            End Select 
        Next ctr 
End Sub

Answer : Control lock Question

You need to add the acCommandButton constant to tell your Select Case to also consider Command buttons;

Case acTextBox, acListBox, acComboBox, acCommandButton

Here's the various Control Types for Access:

http://msdn.microsoft.com/en-us/library/aa224135(office.11).aspx
Random Solutions  
 
programming4us programming4us