I have a basic publisher's Content Management database which contains among other things articles and their respective subject categories and subcategories. The categories and subcategories are displayed in a subform. Each article can have multiple category/subcategory assignment and these are stored in a simple table. The SubForm control source is this table.
ArticleID
CategoryID
SubCategoryID
In the SubForm (CategoryIndexSubForm), there are the two fields, category and subcategory. To make these updatable in the subform, I have made them combo boxes.
The Row Source for category is (a query):
SELECT Categories.CategoryName, Categories.CategoryID FROM Categories;
This is bound to the correct field and I use the 1";0" trick in the Format
The Row Source for subcategory is (a query):
SELECT Subcategories.SubCategoryName, Subcategories.SubCategoryID
FROM Subcategories
WHERE (((Subcategories.CategoryID)=[Forms]![Main]![CategoryIndexSubForm]![CategoryID]));
This is bound to the correct field and I use the 1";0" trick in the Format
In the subform, on the subcategory combo box I have the following onGotFocus event:
Private Sub SubCategoryID_GotFocus()
SubCategoryID.Requery
End Sub
That's it. A user enters a new category/subcategory combination in the subform. They click on the category combo box which populates with all the available categories. Then they click on the subcategory combo box, the requery executes and they get a nice list of the available subcategories for that record's category selection. It works.
But here's the problem... When there are multiple records in the subform, as soon as the subcategory combo box is clicked, all the other previous subcategory assignments in the subform disappear! They are still there, I can make them re-appear by clicking on the subcategory field. But basically only the subcategory that is in focus is visible, the rest are blank (even though there is something there). When I change records in the Main form, I get that same behavior... only the first record in the subform is populated with both category and subcategory. Subsequent records in the subform might contain data in the subcategory field, but like I said, it shows blank.
Does anyone have any suggestions? Do I need to place more refreshes and requery events somwehere else in the subform or on the main form? I've tried most everything.
ArticleID
CategoryID
SubCategoryID
In the SubForm (CategoryIndexSubForm), there are the two fields, category and subcategory. To make these updatable in the subform, I have made them combo boxes.
The Row Source for category is (a query):
SELECT Categories.CategoryName, Categories.CategoryID FROM Categories;
This is bound to the correct field and I use the 1";0" trick in the Format
The Row Source for subcategory is (a query):
SELECT Subcategories.SubCategoryName, Subcategories.SubCategoryID
FROM Subcategories
WHERE (((Subcategories.CategoryID)=[Forms]![Main]![CategoryIndexSubForm]![CategoryID]));
This is bound to the correct field and I use the 1";0" trick in the Format
In the subform, on the subcategory combo box I have the following onGotFocus event:
Private Sub SubCategoryID_GotFocus()
SubCategoryID.Requery
End Sub
That's it. A user enters a new category/subcategory combination in the subform. They click on the category combo box which populates with all the available categories. Then they click on the subcategory combo box, the requery executes and they get a nice list of the available subcategories for that record's category selection. It works.
But here's the problem... When there are multiple records in the subform, as soon as the subcategory combo box is clicked, all the other previous subcategory assignments in the subform disappear! They are still there, I can make them re-appear by clicking on the subcategory field. But basically only the subcategory that is in focus is visible, the rest are blank (even though there is something there). When I change records in the Main form, I get that same behavior... only the first record in the subform is populated with both category and subcategory. Subsequent records in the subform might contain data in the subcategory field, but like I said, it shows blank.
Does anyone have any suggestions? Do I need to place more refreshes and requery events somwehere else in the subform or on the main form? I've tried most everything.