PC Review


Reply
Thread Tools Rate Thread

ComboBox.visible = False or True

 
 
Charlie
Guest
Posts: n/a
 
      21st Dec 2007
This code shows updates the worksheet cell when ComboBox1 is changed. Then
it updates CombBox2 to reflect this new change.

Private Sub ComboBox1_Change()
Worksheets("sheet1").Range("C16") = Me.ComboBox1.Value
CombBox2 = Worksheets("Sheet1").Range("B23").Value
End Sub

....now if this ComboBox2 doesn't have a value, I want to combobox itself to
be visible=Fasle.
I could add another line in the above code to do this, right? I tried
adding this, but it didn't work:

If ComboBox2 .Value = "" Then
ComboBox2 .Visible = False
Else
ComboBox2 .Visible = True
End If

....am I close to getting it?
 
Reply With Quote
 
 
 
 
JLGWhiz
Guest
Posts: n/a
 
      21st Dec 2007
Try ComboBox2.Hidden = True

"Charlie" wrote:

> This code shows updates the worksheet cell when ComboBox1 is changed. Then
> it updates CombBox2 to reflect this new change.
>
> Private Sub ComboBox1_Change()
> Worksheets("sheet1").Range("C16") = Me.ComboBox1.Value
> CombBox2 = Worksheets("Sheet1").Range("B23").Value
> End Sub
>
> ...now if this ComboBox2 doesn't have a value, I want to combobox itself to
> be visible=Fasle.
> I could add another line in the above code to do this, right? I tried
> adding this, but it didn't work:
>
> If ComboBox2 .Value = "" Then
> ComboBox2 .Visible = False
> Else
> ComboBox2 .Visible = True
> End If
>
> ...am I close to getting it?

 
Reply With Quote
 
JLGWhiz
Guest
Posts: n/a
 
      21st Dec 2007
No, that won't work, but Me.Controls.ComboBox2.Visible = False might.

"Charlie" wrote:

> This code shows updates the worksheet cell when ComboBox1 is changed. Then
> it updates CombBox2 to reflect this new change.
>
> Private Sub ComboBox1_Change()
> Worksheets("sheet1").Range("C16") = Me.ComboBox1.Value
> CombBox2 = Worksheets("Sheet1").Range("B23").Value
> End Sub
>
> ...now if this ComboBox2 doesn't have a value, I want to combobox itself to
> be visible=Fasle.
> I could add another line in the above code to do this, right? I tried
> adding this, but it didn't work:
>
> If ComboBox2 .Value = "" Then
> ComboBox2 .Visible = False
> Else
> ComboBox2 .Visible = True
> End If
>
> ...am I close to getting it?

 
Reply With Quote
 
Charlie
Guest
Posts: n/a
 
      21st Dec 2007
I couldn't get that to work: I said combobox, but meant textbox, earlier, so
let me start over:

I have ComboBox1 & TextBox1. A change is made to ComboBox1, which affects
TextBox1. If TextBox1 is blank (no string), then I need the property
..visible of TextBox1 to be set to False. I think this all happens here?

Private Sub ComboBox1_Change()
Worksheets("sheet1").Range("C16") = Me.ComboBox1.Value
TextBox1 = Worksheets("Sheet1").Range("B23").Value
If TextBox1.Value = "" Then
Me.Controls.TextBox1.Visible = False
Else
Me.Controls.Text1.Visible = True
End If
End Sub

....but the line Me.Controls.Text1.Visible gives me an error.
It must be close to being right...

 
Reply With Quote
 
Chip Pearson
Guest
Posts: n/a
 
      21st Dec 2007
> ...but the line Me.Controls.Text1.Visible gives me an error.

You use the Controls collection when you want to refer to a control by its
name. E.g.,

Me.Controls("TextBox1").Visible = False

If you are referring directly to the control, omit the Controls reference:

Me.TextBox1.Visible = False


--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)

"Charlie" <(E-Mail Removed)> wrote in message
news:74A9CFC8-54C2-4F52-A217-(E-Mail Removed)...
>I couldn't get that to work: I said combobox, but meant textbox, earlier,
>so
> let me start over:
>
> I have ComboBox1 & TextBox1. A change is made to ComboBox1, which affects
> TextBox1. If TextBox1 is blank (no string), then I need the property
> .visible of TextBox1 to be set to False. I think this all happens here?
>
> Private Sub ComboBox1_Change()
> Worksheets("sheet1").Range("C16") = Me.ComboBox1.Value
> TextBox1 = Worksheets("Sheet1").Range("B23").Value
> If TextBox1.Value = "" Then
> Me.Controls.TextBox1.Visible = False
> Else
> Me.Controls.Text1.Visible = True
> End If
> End Sub
>
> ...but the line Me.Controls.Text1.Visible gives me an error.
> It must be close to being right...
>


 
Reply With Quote
 
Charlie
Guest
Posts: n/a
 
      21st Dec 2007
I made to typing error Me.Controls.Text1
I fixed to Me.Controls.TextBox1 but it still doesn't work...
 
Reply With Quote
 
Susan
Guest
Posts: n/a
 
      21st Dec 2007
> If TextBox1.Value = "" Then
> Me.Controls.TextBox1.Visible = False
> Else
> Me.Controls.Text1.Visible = True
> End If


TYPO
Me.Controls.TextBox1.Visible = True

susan


On Dec 21, 11:32*am, Charlie <Char...@discussions.microsoft.com>
wrote:
> I couldn't get that to work: *I said combobox, but meant textbox, earlier, so
> let me start over:
>
> I have ComboBox1 & TextBox1. *A change is made to ComboBox1, which affects
> TextBox1. *If TextBox1 is blank (no string), then I need the property
> .visible of TextBox1 to be set to False. *I think this all happens here?
>
> Private Sub ComboBox1_Change()
> Worksheets("sheet1").Range("C16") = Me.ComboBox1.Value
> TextBox1 = Worksheets("Sheet1").Range("B23").Value
> * *If TextBox1.Value = "" Then
> * * * *Me.Controls.TextBox1.Visible = False
> * *Else
> * * *Me.Controls.Text1.Visible = True
> * *End If
> End Sub
>
> ...but the line * * *Me.Controls.Text1.Visible * * * gives me an error.
> It must be close to being right...


 
Reply With Quote
 
Susan
Guest
Posts: n/a
 
      21st Dec 2007
chip said remove the "controls"

as in
Me.Textbox1.Visible=True

susan


On Dec 21, 11:42*am, Charlie <Char...@discussions.microsoft.com>
wrote:
> I made to typing error *Me.Controls.Text1
> I fixed to *Me.Controls.TextBox1 but it still doesn't work...

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Visible = True and Visible = False =?Utf-8?B?ZHNjMmJqbg==?= Microsoft Access VBA Modules 2 19th Nov 2007 06:56 AM
Switching Panels using Visible =true & Visible=false; Kristof Taveirne Microsoft Dot NET Compact Framework 1 28th Jun 2006 03:50 PM
Switching Panels using Visible =true & Visible=false; Kristof Taveirne Microsoft C# .NET 2 28th Jun 2006 01:47 PM
Visible = False / Visible = True Question david Microsoft Access Form Coding 0 14th Apr 2004 08:48 PM
Re: Visible = False / Visible = True Question Dirk Goldgar Microsoft Access Form Coding 0 14th Apr 2004 07:31 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:32 PM.