VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Set all controls in a form to read only (Control.Enabled = False) except the controls given in an a

by merror (3 Submissions)
Category: Custom Controls/Forms/Menus
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Thu 23rd March 2000
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Set all controls in a form to read only (Control.Enabled = False) except the controls given in an array.

Rate Set all controls in a form to read only (Control.Enabled = False) except the controls given in an a



Dim MyControl As Control
Dim MyArrayField As Variant
''21.3.2000 merror
   
   On Error GoTo Err_SetFormToReadOnly
   
   For Each MyControl In frmName.Controls
      ''Activebar doesn''t have a .enabled property
      If Not TypeOf MyControl Is ActiveBar Then MyControl.Enabled = False
      
      
      If TypeOf MyControl Is frame Then MyControl.Enabled = True
      If TypeOf MyControl Is StatusBar Then MyControl.Enabled = True
      If TypeOf MyControl Is Label Then MyControl.Enabled = True
      
      For Each MyArrayField In CtrlsToKeepEnabled
            If MyControl.Name = MyArrayField Then
            MyControl.Enabled = True
         End If
      Next
   Next

Exit_SetFormToReadOnly:
  Exit Sub

Err_SetFormToReadOnly:
  ''Here the Code for my specific Error-Handling
  Resume Exit_SetFormToReadOnly

End Sub


Download this snippet    Add to My Saved Code

Set all controls in a form to read only (Control.Enabled = False) except the controls given in an a Comments

No comments have been posted about Set all controls in a form to read only (Control.Enabled = False) except the controls given in an a. Why not be the first to post a comment about Set all controls in a form to read only (Control.Enabled = False) except the controls given in an a.

Post your comment

Subject:
Message:
0/1000 characters