#1   Report Post  
mully
 
Posts: n/a
Default Disable Text Box

Hi All

I have a UserForm with 20 Text Boxes and some times TBox1,TBox2,TBox3, do
not need information to be entered is it possible to disable these 3 TBoxes
and the others to run as the code dictates.

Any much appreciated

Cheers -- Mully


  #2   Report Post  
Norman Jones
 
Posts: n/a
Default

Hi Mully,

To disable the textbox, the enabled property can be set to False:

Me.TextBox1.Enabled = False

Alternatively, the textbox can be hidden:

Me.TextBox1.Visible = False

---
Regards,
Norman



"mully" wrote in message
...
Hi All

I have a UserForm with 20 Text Boxes and some times TBox1,TBox2,TBox3, do
not need information to be entered is it possible to disable these 3
TBoxes
and the others to run as the code dictates.

Any much appreciated

Cheers -- Mully




  #3   Report Post  
mully
 
Posts: n/a
Default

Hi Norman

Thanks for quick response --- should have put this in 1st question -- could
I place a check box next to the 3 text boxes and just click on it and the
boxes would be greyed out.

"Norman Jones" wrote:

Hi Mully,

To disable the textbox, the enabled property can be set to False:

Me.TextBox1.Enabled = False

Alternatively, the textbox can be hidden:

Me.TextBox1.Visible = False

---
Regards,
Norman



"mully" wrote in message
...
Hi All

I have a UserForm with 20 Text Boxes and some times TBox1,TBox2,TBox3, do
not need information to be entered is it possible to disable these 3
TBoxes
and the others to run as the code dictates.

Any much appreciated

Cheers -- Mully





  #4   Report Post  
Norman Jones
 
Posts: n/a
Default

Hi Mully,

Private Sub CheckBox1_Click()
Me.TextBox1.Enabled = Not Me.CheckBox1.Value
End Sub


---
Regards,
Norman



"mully" wrote in message
...
Hi Norman

Thanks for quick response --- should have put this in 1st question --
could
I place a check box next to the 3 text boxes and just click on it and the
boxes would be greyed out.

"Norman Jones" wrote:

Hi Mully,

To disable the textbox, the enabled property can be set to False:

Me.TextBox1.Enabled = False

Alternatively, the textbox can be hidden:

Me.TextBox1.Visible = False

---
Regards,
Norman



"mully" wrote in message
...
Hi All

I have a UserForm with 20 Text Boxes and some times TBox1,TBox2,TBox3,
do
not need information to be entered is it possible to disable these 3
TBoxes
and the others to run as the code dictates.

Any much appreciated

Cheers -- Mully







  #5   Report Post  
Dkso
 
Posts: n/a
Default

You will need to put this bit of code:
TBox1.Enabled = False
TBox2.Enabled=False
....
....
TBox4.SetFocus
Into the code where the decision to disable the Textboxes is made. The last
line will give TBox4 the focus and should put the cursor into it.

HTH
Dean

"mully" wrote in message
...
Hi All

I have a UserForm with 20 Text Boxes and some times TBox1,TBox2,TBox3, do
not need information to be entered is it possible to disable these 3
TBoxes
and the others to run as the code dictates.

Any much appreciated

Cheers -- Mully






  #6   Report Post  
Norman Jones
 
Posts: n/a
Default

Hi Mully,

My last response was aimed at a single textbox.

To disable / re-enable the three specified textboxes (say TextBox1, TextBox2
and TextBox3) in response to a checkbox (CheckBox1), try:

'==========================
Private Sub CheckBox1_Click()

Me.TextBox1.Enabled = Not Me.CheckBox1.Value
Me.TextBox2.Enabled = Not Me.CheckBox1.Value
Me.TextBox3.Enabled = Not Me.CheckBox1.Value

End Sub
'<<==========================


If you additionally want to apply / remove a grey background to the three
textboxes, try instead:

'==========================
Private Sub CheckBox1_Click()

With Me.TextBox1 <<========= CHANGE
If Not Me.CheckBox1 Then
.Enabled = True
.BackColor = &H80000005
Else
.Enabled = False
.BackColor = &H80000000
End If
End With

With Me.TextBox2 <<========= CHANGE

If Not Me.CheckBox1 Then
.Enabled = True
.BackColor = &H80000005
Else
.Enabled = False
.BackColor = &H80000000
End If
End With

With Me.TextBox3 <<========= CHANGE

If Not Me.CheckBox1 Then
.Enabled = True
.BackColor = &H80000005
Else
.Enabled = False
.BackColor = &H80000000
End If
End With

End Sub
'==========================

Change the textbox names to accord with your needs.

---
Regards,
Norman



"mully" wrote in message
...
Hi Norman

Thanks for quick response --- should have put this in 1st question --
could
I place a check box next to the 3 text boxes and just click on it and the
boxes would be greyed out.

"Norman Jones" wrote:

Hi Mully,

To disable the textbox, the enabled property can be set to False:

Me.TextBox1.Enabled = False

Alternatively, the textbox can be hidden:

Me.TextBox1.Visible = False

---
Regards,
Norman



"mully" wrote in message
...
Hi All

I have a UserForm with 20 Text Boxes and some times TBox1,TBox2,TBox3,
do
not need information to be entered is it possible to disable these 3
TBoxes
and the others to run as the code dictates.

Any much appreciated

Cheers -- Mully







  #7   Report Post  
mully
 
Posts: n/a
Default

Hi Norman

Thanks worked perfectly first time

Once again Thank you

Cheers -- Mully

"Norman Jones" wrote:

Hi Mully,

Private Sub CheckBox1_Click()
Me.TextBox1.Enabled = Not Me.CheckBox1.Value
End Sub


---
Regards,
Norman



"mully" wrote in message
...
Hi Norman

Thanks for quick response --- should have put this in 1st question --
could
I place a check box next to the 3 text boxes and just click on it and the
boxes would be greyed out.

"Norman Jones" wrote:

Hi Mully,

To disable the textbox, the enabled property can be set to False:

Me.TextBox1.Enabled = False

Alternatively, the textbox can be hidden:

Me.TextBox1.Visible = False

---
Regards,
Norman



"mully" wrote in message
...
Hi All

I have a UserForm with 20 Text Boxes and some times TBox1,TBox2,TBox3,
do
not need information to be entered is it possible to disable these 3
TBoxes
and the others to run as the code dictates.

Any much appreciated

Cheers -- Mully








  #8   Report Post  
mully
 
Posts: n/a
Default

Hi Norman & Dkso

Gentlemen used both sets of code the text boxes now disable and colour grey
and the curser drops into the correct box ( Next in line ) absolutely
brilliant and spot on.

Thanks for all your help

Cheers Mully

"Norman Jones" wrote:

Hi Mully,

My last response was aimed at a single textbox.

To disable / re-enable the three specified textboxes (say TextBox1, TextBox2
and TextBox3) in response to a checkbox (CheckBox1), try:

'==========================
Private Sub CheckBox1_Click()

Me.TextBox1.Enabled = Not Me.CheckBox1.Value
Me.TextBox2.Enabled = Not Me.CheckBox1.Value
Me.TextBox3.Enabled = Not Me.CheckBox1.Value

End Sub
'<<==========================


If you additionally want to apply / remove a grey background to the three
textboxes, try instead:

'==========================
Private Sub CheckBox1_Click()

With Me.TextBox1 <<========= CHANGE
If Not Me.CheckBox1 Then
.Enabled = True
.BackColor = &H80000005
Else
.Enabled = False
.BackColor = &H80000000
End If
End With

With Me.TextBox2 <<========= CHANGE

If Not Me.CheckBox1 Then
.Enabled = True
.BackColor = &H80000005
Else
.Enabled = False
.BackColor = &H80000000
End If
End With

With Me.TextBox3 <<========= CHANGE

If Not Me.CheckBox1 Then
.Enabled = True
.BackColor = &H80000005
Else
.Enabled = False
.BackColor = &H80000000
End If
End With

End Sub
'==========================

Change the textbox names to accord with your needs.

---
Regards,
Norman



"mully" wrote in message
...
Hi Norman

Thanks for quick response --- should have put this in 1st question --
could
I place a check box next to the 3 text boxes and just click on it and the
boxes would be greyed out.

"Norman Jones" wrote:

Hi Mully,

To disable the textbox, the enabled property can be set to False:

Me.TextBox1.Enabled = False

Alternatively, the textbox can be hidden:

Me.TextBox1.Visible = False

---
Regards,
Norman



"mully" wrote in message
...
Hi All

I have a UserForm with 20 Text Boxes and some times TBox1,TBox2,TBox3,
do
not need information to be entered is it possible to disable these 3
TBoxes
and the others to run as the code dictates.

Any much appreciated

Cheers -- Mully








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
Count Intervals of Filtered TEXT values in Column and Return Count across a Row Sam via OfficeKB.com Excel Worksheet Functions 9 July 31st 05 03:37 AM
Text Wrapping JMB Excel Discussion (Misc queries) 0 July 29th 05 02:41 AM
Formulas dealing with text data Bagia Excel Worksheet Functions 6 June 20th 05 10:29 PM
Sort or Filter option? Mcobra41 Excel Worksheet Functions 3 February 23rd 05 07:22 PM
Read Text File into Excel Using VBA Willie T Excel Discussion (Misc queries) 13 January 8th 05 12:37 AM


All times are GMT +1. The time now is 11:44 PM.

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

About Us

"It's about Microsoft Excel"