Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Locking all text, combo and check boxes

Hello,
I have a user form with several text, combo and checkboxes, as well as
command buttons.
I would like for the user to check a check box and lock all txt,cmb and chk
boxes in the form once they are entering the data, but I want to keep the cmd
buttons enabled, so I do not need to lock the whole userform.

I would like to see if there is a way to do this in a "batch", for example
If chkbox1= True then "All txtboxes".Locked=True
I would hate to name every single one.

Thank you

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 131
Default Locking all text, combo and check boxes

You can loop through the controls collection on your form. If you've
followed a good naming convention (i.e. command buttons are named something
like cmdName) then snippet below would work:

Sub LockControls()

Dim myCtrl as Control

For Each myCtrl in me.Controls
If Right(myCtrl.Name, 3) < "cmd" Then myCtrl.Locked = True
Next myCtrl

End Sub

"Memphis" wrote:

Hello,
I have a user form with several text, combo and checkboxes, as well as
command buttons.
I would like for the user to check a check box and lock all txt,cmb and chk
boxes in the form once they are entering the data, but I want to keep the cmd
buttons enabled, so I do not need to lock the whole userform.

I would like to see if there is a way to do this in a "batch", for example
If chkbox1= True then "All txtboxes".Locked=True
I would hate to name every single one.

Thank you

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 131
Default Locking all text, combo and check boxes

Ahem. Uh, yes, that should have been the "other Right"...

If Left(myCtrl.Name, 3) < "cmd" Then myCtrl.Locked = True

"B Lynn B" wrote:

You can loop through the controls collection on your form. If you've
followed a good naming convention (i.e. command buttons are named something
like cmdName) then snippet below would work:

Sub LockControls()

Dim myCtrl as Control

For Each myCtrl in me.Controls
If Right(myCtrl.Name, 3) < "cmd" Then myCtrl.Locked = True
Next myCtrl

End Sub

"Memphis" wrote:

Hello,
I have a user form with several text, combo and checkboxes, as well as
command buttons.
I would like for the user to check a check box and lock all txt,cmb and chk
boxes in the form once they are entering the data, but I want to keep the cmd
buttons enabled, so I do not need to lock the whole userform.

I would like to see if there is a way to do this in a "batch", for example
If chkbox1= True then "All txtboxes".Locked=True
I would hate to name every single one.

Thank you

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Drag and drop text in userform text / combo boxes Roger on Excel Excel Programming 1 November 22nd 09 11:34 AM
Getting Combo boxes to change options based on other Combo boxes. Ancient Wolf New Users to Excel 1 March 27th 09 06:29 PM
How can I sum up several check boxes conditioned by a combo box? [email protected] Excel Discussion (Misc queries) 4 December 13th 08 12:22 PM
locking check boxes using a macro Erik Andreassen[_2_] Excel Programming 3 June 24th 05 07:40 PM
filling text boxes from a combo box JT[_2_] Excel Programming 1 February 21st 05 04:03 PM


All times are GMT +1. The time now is 09:30 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"