Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Contextual Combo Box?

Status
Not open for further replies.

cliffilc

Programmer
Oct 17, 2001
2
US
I am a new Access programmer and I have the following problem:

I am creating a product feature tracking database. The Main table is Feature containing the following fields:
Name
Category
SubCategory

Here are the two related tables
Category
---------
ID
Name
Priority

SubCategory
-----------
ID
Name
Priority
CategoryID

There are a number of records in Subcategory for each specific Category. What I want to do is to present a ComboBox on the Feature form that presents the relevant records from SubCategory depending on what is selected for Category. This requires that I be able to determine the contents of the Category field from the Feature record. Is this possible?
Thanks
-cliff


 
My first suggestion is that you create an ID field in the Feature table - an ID field should never derived by users (even those of us that maintain dbs).

That being said, the combo box is Bound, by default, to the first column. In other words, if you have a single column or multi column combo box the value of it is determined by the first column (which is column(0) because the control is zero-based). Use the wizard to create the combo box and base it on a query of the Feature table. From my understanding of your table, Name is the ID, place it first in the query grid and name will be in the first column in the column (the bound column).

Base the subform on a parameterized query that has its parameter the value of the combo box. In the Name (I think that is the link) field of the query builder place this:

Forms![frmFeature]![MyComboBox]


On the combo box's AfterUpdate event put this

me.frmSubCatagorySub.Form.Requery

That should requery the subform based on the value of the combo box

Hope that helps.


Bob
 
Bob, thanks for your help. i still have questions. First of all, Features does have an ID field, I left it out of my description thinking that would simplify things. I don't understand your methodology with the subform. I'm trying to create a select statement like
SELECT SubCategory.ID, SubCategory.NAME where Subcategory.CategoryID = <<value of Feature.Category for this row>>
Thanks for your help, clearly I'm still confused.
-cliff
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top