Hierarchical combos

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



I am trying to build a database that will sort a large number of publications
by category, then subcategory. To enter details of a publication, the user
selects a category from cboCategory and then a subcategory on cboSubcategory
on main form (fmAddNew). Then the user records title, date, author etc. in
textboxes on a subform. The subform is based on tblPublications, where all
fields for each publication are recorded. The master, child links between the
main form and subform are SubcategoryID.
The relationships are tblCategory to tblSubcategory (one to many) and then
tblSubcategory to tblPublications (one to many).

The rowsource for cboCategory is
SELECT tblCategories.CategoryID, tblCategories.Category FROM tblCategories;

The AfterUpdate includes:
Private Sub ComboCategory_AfterUpdate()

' if Category is updated then erase current values
' for Subcategory and requery combo box
' to show Subcategories of selected Category
Me!ComboSubcategory = Null
Me!ComboSubcategory.Requery

For comboSubcategory
RowSource:
SELECT tblSubcategories.SubcategoryID, tblSubcategories.Subcategory FROM
tblSubcategories WHERE tblSubcategories.CategoryID=Form!comboCategory ORDER
BY tblSubcategories.Subcategory;

AfterUpdate code:
Private Sub ComboSubcategory_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[SubcategoryID] = " & Str(Nz(Me![ComboSubcategory], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub

The problem is that I cannot get SubcategoryID to record into
tblPublications each time a new publication is entered into the database.

Subsequently, I would like to be able to search the database on another form
(fmSearch) through the same combos and allow the user to select their
preferred publication title from a drop-down list. Once the publication is
chosen, then all details pertaining to that publication are displayed on
fmSearch.

However, this is not possible because of the problem with recording
SubcategoryID onto tblPublications.

I hope this all makes sense. I am using Access2003.
any advice appreciated.
SJW
.



Relevant Pages

  • Re: Hierarchical cbos to be used in search
    ... To add a subcategory, the database needs to know which category to add the ... Because tblSubcategories is upstream of tblPublications, ... new publication, you have to know the ID field for the upstream table. ... --The subform on frmAddNew has tblPublications for its recordsource. ...
    (microsoft.public.access.gettingstarted)
  • Re: Hierarchical cbos to be used in search
    ... tblPublications is downstream from both tblSubcategories and tblCategories ... To add a subcategory, the database needs to know which category to add the ... new publication, you have to know the ID field for the upstream table. ... --The subform on frmAddNew has tblPublications for its recordsource. ...
    (microsoft.public.access.gettingstarted)
  • Re: Hierarchical cbos to be used in search
    ... been using tblSubcategories which delivers subcategoryID and subcategory ... The combos category and subcategory work OK on main ... properties of this subform it states "source object Subform Publications" ... new publication, you have to know the ID field for the upstream table. ...
    (microsoft.public.access.gettingstarted)
  • Re: Hierarchical combos
    ... ' for Subcategory and requery combo box ... Private Sub ComboSubcategory_AfterUpdate ... tblPublications each time a new publication is entered into the ... I would like to be able to search the database on ...
    (microsoft.public.access.gettingstarted)
  • Re: Hierarchical cbos to be used in search
    ... fmAddNew would not run when a querySubcategory was the recordsource. ... The combos category and subcategory work OK on main form. ... I made the subform based on tblPublications (however, ... new publication, you have to know the ID field for the upstream table. ...
    (microsoft.public.access.gettingstarted)