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

Access combo-box

P: 6
Returning to Access after years of break!

Have combo box on form populated with 3 records:

Height
Weight
Width

I wish to make height fields visible on the form if I select height, but others remain invisible.

When I select weight, then the height fields become invisible and the weight fields become visible.

Help here is greatly appreciated.
Feb 12 '07 #1
Share this Question
Share on Google+
5 Replies


MMcCarthy
Expert Mod 10K+
P: 14,534
In the AfterUpdate event of the combobox put the following code (adapted to your control names)

Expand|Select|Wrap|Line Numbers
  1. Private Sub comboBoxName_AfterUpdate()
  2.  
  3.   SELECT CASE ComboBoxName.Value
  4.     CASE "Height"
  5.       Me.txtHeight.Visible = True
  6.       Me.txtWeight.Visible = False
  7.       Me.txtWidth.Visible = False
  8.     CASE "Weight"
  9.       Me.txtHeight.Visible = False
  10.       Me.txtWeight.Visible = True
  11.       Me.txtWidth.Visible = False
  12.     CASE "Width"
  13.       Me.txtHeight.Visible = False
  14.       Me.txtWeight.Visible = False
  15.       Me.txtWidth.Visible = True
  16.   End SELECT
  17.  
  18. End Sub
  19.  
Mary
Feb 12 '07 #2

NeoPa
Expert Mod 15k+
P: 31,186
This code should work too.
It's a bit more expandable (Easier to add extra levels of selection).
Expand|Select|Wrap|Line Numbers
  1. Private Sub cboBox_AfterUpdate()
  2.     Me!txtHeight.Visible = (Me!cboBox = "Height")
  3.     Me!txtWeight.Visible = (Me!cboBox = "Weight")
  4.     Me!txtWidth.Visible = (Me!cboBox = "Width")
  5. End Sub
Feb 12 '07 #3

P: 6
Thank you, Mary and NeoPa--

That's just fine
Feb 13 '07 #4

NeoPa
Expert Mod 15k+
P: 31,186
Pleased to hear it's working for you :)
Feb 13 '07 #5

MMcCarthy
Expert Mod 10K+
P: 14,534
Pleased to hear it's working for you :)
You're welcome.
Feb 13 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.