By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,480 Members | 1,231 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,480 IT Pros & Developers. It's quick & easy.

Hide a combo box

P: n/a
Good morning,

I have 5 combo boxes that i need to hide when a text box has a certain
name in it. I have tried the following, which works, but i have to
select the box for it to work. I want the boxes to hide as soon as his
last name is in the combo box "LastName".

Private Sub LastName_GotFocus()
If LastName = "Herbst" Then
Supplier1.Visible = False
Else
Supplier1.Visible = True
End If
End Sub
Tempy

*** Sent via Developersdex http://www.developersdex.com ***
Nov 13 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
"Tempy" <an*******@devdex.com> wrote in message
news:Yv************@news.uswest.net...
Good morning,

I have 5 combo boxes that i need to hide when a text box has a certain
name in it. I have tried the following, which works, but i have to
select the box for it to work. I want the boxes to hide as soon as his
last name is in the combo box "LastName".

Private Sub LastName_GotFocus()
If LastName = "Herbst" Then
Supplier1.Visible = False
Else
Supplier1.Visible = True
End If
End Sub


Put this code in the form's On Current event:

If Me.txtMyTextBox = "Whatever" Then
Me.MyCombo1.Visible = False
Me.MyCombo2.Visible = False
Else
Me.MyCombo1.Visible = True
Me.MyCombo2.Visible = True
End If

Substitute the generic names for your actual names.

HTH - Keith.
www.keithwilby.com
Nov 13 '05 #2

P: n/a
Thanks Kieth, works great.

Tempy

*** Sent via Developersdex http://www.developersdex.com ***
Nov 13 '05 #3

P: n/a
Hello Kieth,

Sorry for the probably simple questions, but a newbie to this game. I
have a command button next to the boxes that i also need to hide, i
tried:

Me!AddSupplierBuy = False

It does not like this, is there different code for a button ?

Tempy

*** Sent via Developersdex http://www.developersdex.com ***
Nov 13 '05 #4

P: n/a
"Tempy" <an*******@devdex.com> wrote in message
news:Qa*************@news.uswest.net...
Hello Kieth,

Sorry for the probably simple questions, but a newbie to this game. I
have a command button next to the boxes that i also need to hide, i
tried:

Me!AddSupplierBuy = False

It does not like this, is there different code for a button ?

Tempy

You have not set the .Visible property of the button to false.
Nov 13 '05 #5

P: n/a
"Tempy" <an*******@devdex.com> wrote in message
news:Qa*************@news.uswest.net...
Hello Kieth,
Me!AddSupplierBuy = False

It does not like this, is there different code for a button ?


You've just missed off the property you're trying to change:

Me.AddSupplierBuy.Visible = False

Note that using "." instead of "!" invokes the VBA auto-complete feature.

Regards,
Keith (not Kieth ;-)).
Nov 13 '05 #6

P: n/a
Thanks so much Keith 100 %.

Tempy

*** Sent via Developersdex http://www.developersdex.com ***
Nov 13 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.