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

ComboBox to Control Specific Field Display

P: 2
I am try to limit the fields that are displayed in a subform based on the selection of the combo box.
The table has a StudentName, test1, test2, and test3 among other fields.
I am trying to create a form that will only display the student name and one of the test fields based on a combo box selection.
How can i do this, or is there a better way go about it?

Thanks
Oct 7 '08 #1
Share this Question
Share on Google+
3 Replies


NeoPa
Expert Mod 15k+
P: 31,709
This is possible to do, but you will need to make your question clearer.

What determines which control, of which set of controls, should be displayed?
Oct 8 '08 #2

P: 2
I hope this makes it clearer. In the main form all i want to have is the combo box for selecting the field test1, 2, or 3. Then in the sub form the only fields from the table to be displayed would be the StudentName (which would always show) and then the Test 1, 2, or 3 to input their grade depending upon the selection of the combo box.

I know this can be done through setting the combo box to display the field names, but the challenge i am running into is that i do not want create a separate table for the test scores (if i don't have to) so currently when try to set the combo box to display the fields, i am displaying all the fields from the table and not just the three i want to choose from.
Oct 8 '08 #3

NeoPa
Expert Mod 15k+
P: 31,709
Assumptions (As you don't share the names you use, or much really, I'll invent some and you can translate) :
  1. We have an unbound ComboBox control (called cboSelect) on your main form which returns values 1, 2 or 3.
  2. We have a SubForm control named sbfTest on the main form.
  3. We have three controls on the subform called txtTest1, txtTest2 & txtTest3.
You can design the three TextBoxes to be invisible. They can also be designed to take up the same space on the subform, as only one will be visible at any one time.
In the AfterUpdate procedure of the ComboBox (cboSelect) select which TextBox is visible :
Expand|Select|Wrap|Line Numbers
  1. Private Sub cboSelect_AfterUpdate()
  2.   With Me.sbfTest.Form
  3.     .txtTest1.Visible = (Me.cboSelect=1)
  4.     .txtTest2.Visible = (Me.cboSelect=2)
  5.     .txtTest3.Visible = (Me.cboSelect=3)
  6.   End With
  7. End Sub
Let us know how you get on with this.
Oct 8 '08 #4

Post your reply

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