Results 1 to 6 of 6

Thread: Categories and Subcategories

  1. #1
    Join Date
    Mar 2004
    Posts
    3

    Categories and Subcategories

    I am trying to construct a database with Access 2002 to keep articles from a magazine to a usable archive.
    Each articles has to be in a Category. Each category has many subcategories.

    My problem is that when I insert a new article in the database I have to choose between all the subcategories even though i already selected a category.

    Is there a way to see only the appropriate subcategories for each category i choose during the data entry?

    Is it the relations between the tables Categories and Subcategories?

    Thank you

  2. #2
    Join Date
    Jan 2003
    Location
    UK
    Posts
    277
    do you have a common field that links the 2 tables such as categoryID ?

    how are you inserting a new article in the database ? with a form ?

    Do you need to filter the subcategories based on a category that is entered ?

  3. #3
    Join Date
    Mar 2004
    Posts
    3
    The common field between tables Categories and Subcategoris is called Category.

    I use a form to enter Articles.

    Yes, I want to filter subcategories when I insert a new Article in the database, in order to be able to choose between them according to the Category already chosen.

    Attached a similar database.
    Attached Files Attached Files

  4. #4
    Join Date
    Feb 2003
    Location
    Earth, USA
    Posts
    81

    AfterUpdate Event

    I downloaded your file and noticed some interesting naming conventions, I suspect that since I am still using 2000 it may be a lack of backward compatibility.

    I use a Category and Sub Category relationship in a Check Book Register the Sub Category Row Source is updated on the Categories AfterUpdate Event. In the property view of your Category Combo Box select the Event Tab and enter a "[" in the After Update field. You will note "[Event Procedure]" is automatically inserted press the "..." button to the right this will automatically create a sub routine header and footer.

    Insert the following:

    Dim strSQL as String

    strSQL = "SELECT Category, SubCatName FROM SubCategories ORDER BY SubCatName"

    Me!cboSubCatName.RowSource = strSQL
    Me!cboSubCatName.Requery

    Please note that you may want to have both your Category and SubCatName as key fields in your table SubCategories. There may arise a situation where you have duplicate Sub Categories between different Categories, your current table setting will not allow for this.

    Good Luck!

  5. #5
    Join Date
    Mar 2004
    Posts
    3

    Thanks but...

    a runtime error occured.

    Run time error 2465
    cannot find cboSubCatName...

    the error is in the line

    Me!cboSubCatName.RowSource = strSQL

  6. #6
    Join Date
    Feb 2003
    Location
    Earth, USA
    Posts
    81
    Substitute cboSubCatName with the name you have selected for your combo box, the file that I downloaded was some what encrypted (Backward compatability). I could not read the name you provided for your combo box.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •