Results 1 to 5 of 5
  1. #1
    tomullus is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Oct 2011
    Posts
    2

    Cascade of 3 or more ComboBoxes

    Hi,

    I'm having difficulty with making a cascade of more than 2 combo boxes. Let's say that my Database has a single table (let's call it TableX) containing the following columns: Category, Group, Subgroup, Information. I want to have 3 combo boxes; the first filtering the second and the second filtering the third.

    The first combo box has the following rowsource:

    SELECT DISTINCT TableX.Category FROM TableX;

    and an after update event:

    Private Sub Combo1_AfterUpdate()
    Me!Combo2.Requery
    End Sub

    Now for the second Combobox:
    SELECT DISTINCT TableX.Category, TableX.Group FROM TableX WHERE (((TableX.Category)=[Forms]![MyForm]![Combo1]));

    Up to this point everything works as expected, the third combo box doesn't.
    I've given it the following rowsource (also added an afterupdate event to combo2):

    SELECT DISTINCT TableX.Category, TableX.Group, TableX.Subgroup
    FROM TableX
    WHERE (((TableX.Category)=[Forms]![MyForm]![Combo2]) AND ((TableX.Group)=[Forms]![MyForm]![Combo2]));

    I don't know if I've made a mistake but the third combobox is always blank. The "AND ((TableX.Group)=[Forms]![MyForm]![Combo2]))" part seems to be the problem, because when i lebae the rowsource as:

    SELECT DISTINCT TableX.Category, TableX.Group, TableX.Subgroup
    FROM TableX
    WHERE ((TableX.Category)=[Forms]![MyForm]![Combo2]);

    the combobox works (but obviously doesn't filter how I need it to).



    Any help would be greatly appreciated.

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Are the two ComboBoxes bound to numeric fields? You do realize that you do not need to go through the Forms collection to reference the controls on the corrent form, right?

  3. #3
    tomullus is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Oct 2011
    Posts
    2
    No, the comboboxes are not bound to numeric fields. But the first and second comboboxes work properly no matter what type of data they are bound to. I checked what would happen if I chaned the columns to the numeric data type ,but the problem stays the same.

    I honestly don't understand what do you mean by "going through the forms collection to reference the controls on the current form". Could you be more clear/specific? Sorry for being a dimwit.

    Thanks for the reply.

    EDIT: I fixed it. Issues with column count and bound column. Silly me. Thanks.

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    [Forms]![MyForm]![Combo2]
    ...can be expressed as...
    Me.Combo2

  5. #5
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Is TableX.Category a text field or a numeric one?

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Cascade Lookup or drop down - 2010
    By Tablerone in forum Access
    Replies: 14
    Last Post: 10-04-2011, 04:18 PM
  2. Comboboxes go where?
    By PaulCW in forum Database Design
    Replies: 12
    Last Post: 10-04-2011, 02:34 AM
  3. Replies: 11
    Last Post: 06-30-2011, 11:12 PM
  4. Code for two comboBoxes
    By t_dot in forum Forms
    Replies: 3
    Last Post: 08-24-2010, 10:20 AM
  5. On delete cascade fails in constraint clause
    By Victor EGBE in forum Queries
    Replies: 0
    Last Post: 03-02-2009, 09:52 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums