![]() |
How to make a txtbox not visible
Hello Hello,
How do i make a textbox only visible if the label has a value in it. Example might be in vba there are 10 labels and 10 textboxes. When i activate the form and i have it only three labels fill with information i only want to see txtboxes 1,2,3, to be visible. Need lots of direction . . . thanks. -- Thank you, Jennifer |
How to make a txtbox not visible
Something like....
If Len(Trim(Label1.Caption)) 0 then TextBox1.Visible = True Else TextBox1.Visible = False Endif -- Cheers Nigel "Jennifer" wrote in message ... Hello Hello, How do i make a textbox only visible if the label has a value in it. Example might be in vba there are 10 labels and 10 textboxes. When i activate the form and i have it only three labels fill with information i only want to see txtboxes 1,2,3, to be visible. Need lots of direction . . . thanks. -- Thank you, Jennifer |
How to make a txtbox not visible
Nigal almost . . . it doesn't recognize the label with text in it. Can you
direct me a bit more. Sorry -- Thank you, Jennifer "Nigel" wrote: Something like.... If Len(Trim(Label1.Caption)) 0 then TextBox1.Visible = True Else TextBox1.Visible = False Endif -- Cheers Nigel "Jennifer" wrote in message ... Hello Hello, How do i make a textbox only visible if the label has a value in it. Example might be in vba there are 10 labels and 10 textboxes. When i activate the form and i have it only three labels fill with information i only want to see txtboxes 1,2,3, to be visible. Need lots of direction . . . thanks. -- Thank you, Jennifer |
How to make a txtbox not visible
Ok my reply wasn't total right. If i put text in the label properties
(caption) it works . . . but (there is always a but) when i use this code to fill the labels it doesn't work. Hmmm Private Sub cmdSelect_Click() Dim i As Long Dim SelCount As Long With ListBox1 For i = 0 To .ListCount - 1 If .Selected(i) = True Then SelCount = SelCount + 1 UserForm1.Controls("Label" & SelCount).Caption = .List(i) End If Next End With UserForm1.Show Unload Me -- Thank you, Jennifer "Nigel" wrote: Something like.... If Len(Trim(Label1.Caption)) 0 then TextBox1.Visible = True Else TextBox1.Visible = False Endif -- Cheers Nigel "Jennifer" wrote in message ... Hello Hello, How do i make a textbox only visible if the label has a value in it. Example might be in vba there are 10 labels and 10 textboxes. When i activate the form and i have it only three labels fill with information i only want to see txtboxes 1,2,3, to be visible. Need lots of direction . . . thanks. -- Thank you, Jennifer |
How to make a txtbox not visible
This is a top of the head guess (I'm about to go to sleep, so I didn't test
it); try replacing your With/End With block of code with this instead and see if it works for you... With ListBox1 For i = 0 To .ListCount - 1 If .Selected(i) = True Then SelCount = SelCount + 1 UserForm1.Controls("Label" & SelCount).Caption = .List(i) UserForm1.Controls("TextBox" & _ CStr(SelCount)).Visible = True End If Next For i = SelCount + 1 To 10 UserForm1.Controls("TextBox" & CStr(i)).Visible = False Next End With Rick "Jennifer" wrote in message ... Ok my reply wasn't total right. If i put text in the label properties (caption) it works . . . but (there is always a but) when i use this code to fill the labels it doesn't work. Hmmm Private Sub cmdSelect_Click() Dim i As Long Dim SelCount As Long With ListBox1 For i = 0 To .ListCount - 1 If .Selected(i) = True Then SelCount = SelCount + 1 UserForm1.Controls("Label" & SelCount).Caption = .List(i) End If Next End With UserForm1.Show Unload Me -- Thank you, Jennifer "Nigel" wrote: Something like.... If Len(Trim(Label1.Caption)) 0 then TextBox1.Visible = True Else TextBox1.Visible = False Endif -- Cheers Nigel "Jennifer" wrote in message ... Hello Hello, How do i make a textbox only visible if the label has a value in it. Example might be in vba there are 10 labels and 10 textboxes. When i activate the form and i have it only three labels fill with information i only want to see txtboxes 1,2,3, to be visible. Need lots of direction . . . thanks. -- Thank you, Jennifer |
How to make a txtbox not visible
Thanks Rick but it is getting stopped at
UserForm1.Controls("TextBox" & CStr(i)).Visible = False then highlights the whole line. When i put my curser over the CStr(i)). it reads i=9 Anymore ideas -- Thank you, Jennifer "Rick Rothstein (MVP - VB)" wrote: This is a top of the head guess (I'm about to go to sleep, so I didn't test it); try replacing your With/End With block of code with this instead and see if it works for you... With ListBox1 For i = 0 To .ListCount - 1 If .Selected(i) = True Then SelCount = SelCount + 1 UserForm1.Controls("Label" & SelCount).Caption = .List(i) UserForm1.Controls("TextBox" & _ CStr(SelCount)).Visible = True End If Next For i = SelCount + 1 To 10 UserForm1.Controls("TextBox" & CStr(i)).Visible = False Next End With Rick "Jennifer" wrote in message ... Ok my reply wasn't total right. If i put text in the label properties (caption) it works . . . but (there is always a but) when i use this code to fill the labels it doesn't work. Hmmm Private Sub cmdSelect_Click() Dim i As Long Dim SelCount As Long With ListBox1 For i = 0 To .ListCount - 1 If .Selected(i) = True Then SelCount = SelCount + 1 UserForm1.Controls("Label" & SelCount).Caption = .List(i) End If Next End With UserForm1.Show Unload Me -- Thank you, Jennifer "Nigel" wrote: Something like.... If Len(Trim(Label1.Caption)) 0 then TextBox1.Visible = True Else TextBox1.Visible = False Endif -- Cheers Nigel "Jennifer" wrote in message ... Hello Hello, How do i make a textbox only visible if the label has a value in it. Example might be in vba there are 10 labels and 10 textboxes. When i activate the form and i have it only three labels fill with information i only want to see txtboxes 1,2,3, to be visible. Need lots of direction . . . thanks. -- Thank you, Jennifer |
How to make a txtbox not visible
Are you getting any error message when it stops? If so, what does it say? Do
you, in fact, have a text box named TextBox9 (as opposed to one named TextBox09 for example)? Rick "Jennifer" wrote in message ... Thanks Rick but it is getting stopped at UserForm1.Controls("TextBox" & CStr(i)).Visible = False then highlights the whole line. When i put my curser over the CStr(i)). it reads i=9 Anymore ideas -- Thank you, Jennifer "Rick Rothstein (MVP - VB)" wrote: This is a top of the head guess (I'm about to go to sleep, so I didn't test it); try replacing your With/End With block of code with this instead and see if it works for you... With ListBox1 For i = 0 To .ListCount - 1 If .Selected(i) = True Then SelCount = SelCount + 1 UserForm1.Controls("Label" & SelCount).Caption = .List(i) UserForm1.Controls("TextBox" & _ CStr(SelCount)).Visible = True End If Next For i = SelCount + 1 To 10 UserForm1.Controls("TextBox" & CStr(i)).Visible = False Next End With Rick "Jennifer" wrote in message ... Ok my reply wasn't total right. If i put text in the label properties (caption) it works . . . but (there is always a but) when i use this code to fill the labels it doesn't work. Hmmm Private Sub cmdSelect_Click() Dim i As Long Dim SelCount As Long With ListBox1 For i = 0 To .ListCount - 1 If .Selected(i) = True Then SelCount = SelCount + 1 UserForm1.Controls("Label" & SelCount).Caption = .List(i) End If Next End With UserForm1.Show Unload Me -- Thank you, Jennifer "Nigel" wrote: Something like.... If Len(Trim(Label1.Caption)) 0 then TextBox1.Visible = True Else TextBox1.Visible = False Endif -- Cheers Nigel "Jennifer" wrote in message ... Hello Hello, How do i make a textbox only visible if the label has a value in it. Example might be in vba there are 10 labels and 10 textboxes. When i activate the form and i have it only three labels fill with information i only want to see txtboxes 1,2,3, to be visible. Need lots of direction . . . thanks. -- Thank you, Jennifer |
How to make a txtbox not visible
Your the bomb! Yep i only had 8. Thank you very much.
How about having the form auto size to the number of visible txtboxes? this stuff is so addicting. Do you ever really finish a project! -- Thank you, Jennifer "Rick Rothstein (MVP - VB)" wrote: Are you getting any error message when it stops? If so, what does it say? Do you, in fact, have a text box named TextBox9 (as opposed to one named TextBox09 for example)? Rick "Jennifer" wrote in message ... Thanks Rick but it is getting stopped at UserForm1.Controls("TextBox" & CStr(i)).Visible = False then highlights the whole line. When i put my curser over the CStr(i)). it reads i=9 Anymore ideas -- Thank you, Jennifer "Rick Rothstein (MVP - VB)" wrote: This is a top of the head guess (I'm about to go to sleep, so I didn't test it); try replacing your With/End With block of code with this instead and see if it works for you... With ListBox1 For i = 0 To .ListCount - 1 If .Selected(i) = True Then SelCount = SelCount + 1 UserForm1.Controls("Label" & SelCount).Caption = .List(i) UserForm1.Controls("TextBox" & _ CStr(SelCount)).Visible = True End If Next For i = SelCount + 1 To 10 UserForm1.Controls("TextBox" & CStr(i)).Visible = False Next End With Rick "Jennifer" wrote in message ... Ok my reply wasn't total right. If i put text in the label properties (caption) it works . . . but (there is always a but) when i use this code to fill the labels it doesn't work. Hmmm Private Sub cmdSelect_Click() Dim i As Long Dim SelCount As Long With ListBox1 For i = 0 To .ListCount - 1 If .Selected(i) = True Then SelCount = SelCount + 1 UserForm1.Controls("Label" & SelCount).Caption = .List(i) End If Next End With UserForm1.Show Unload Me -- Thank you, Jennifer "Nigel" wrote: Something like.... If Len(Trim(Label1.Caption)) 0 then TextBox1.Visible = True Else TextBox1.Visible = False Endif -- Cheers Nigel "Jennifer" wrote in message ... Hello Hello, How do i make a textbox only visible if the label has a value in it. Example might be in vba there are 10 labels and 10 textboxes. When i activate the form and i have it only three labels fill with information i only want to see txtboxes 1,2,3, to be visible. Need lots of direction . . . thanks. -- Thank you, Jennifer |
All times are GMT +1. The time now is 03:45 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com