Results 1 to 13 of 13
  1. #1
    sprtrmp is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Sep 2015
    Location
    Greenville, SC
    Posts
    102

    Problem with Cascading Combo Boxes

    I have a table showing products that fall into 8 different categories (shirts, pants, hats, for example) each of these categories is further divided by size (lets say small, medium, large, etc.). all products are on the same table, but there is a foreign key related to another "category" table.

    I am trying to devise a form (based on a query) that will have 2 combo boxes, the first combo will allow me to select one of the 8 top level categories, and the second combo will have a breakdown of different sizes for each of those items.

    how do I get the form to filter by 2 separate combo boxes, then be able to make the record for the size that I have chosen active, so I can make changes to the quantity for THAT record??

    I am sure I didn't include all the information needed, so go ahead and ask away

    Thanks

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Method I prefer for searching and filtering form http://www.allenbrowne.com/ser-62.html
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    sprtrmp is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Sep 2015
    Location
    Greenville, SC
    Posts
    102
    ...anyone? ...anyone?

  4. #4
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    So the new form will be bound to a query that returns all records.
    You will need to have two unbound combo boxes in the form header.

    The first combo box will select the category.
    The second combo box will be limited to the size for that category.
    Then VBA code will be required to set a filter on the form for the category and/or size. This will limit the records that matches the combo boxes.

    Clear as mud?

  5. #5
    sprtrmp is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Sep 2015
    Location
    Greenville, SC
    Posts
    102
    ALSEInventory.zipabsolutely...
    I sort of figured all that, but not in so few words. it was a LOT more confused in my brain.

    I have attached a scaled-down version of what I am working on, basically, it is just 2 forms: one that lists the "categories" and the other that lists the products (ProductCat_FK) that seperates them into the categories on the other table.

    I have a query (qryExpiriment) that I had set up to accept criteria from a combo box on a form (frmExp) to filter the query and show only those items whose ProductID_FK matched what was chosen in the combo box. (I don't know if that is anywhere near right, but at one point, at least that much worked).

    the second combo box on the form should be where I would pick the size and be able to edit the quantity (which is all I really need to do at this point).

    Please see the attached, and let me know where to go from here.

    Thanks
    Mike

  6. #6
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    See if this helps you........ (didn't want to write a book)

    Enjoy.....

  7. #7
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,932
    Try the following - change names to suit.

    Note the use of the name of the first combobox in the second combo rowsource, it should not be the same name as a field in your tblSizes and should be enclosed in square brackets

    Combo1 rowsource (combo called say cboCategories)

    Code:
    SELECT categoryPK, categoryName from tblCategories ORDER BY categoryName
    Combo2 rowsource - note type the sql here, not in a query

    Code:
    SELECT SizePK, SizeDesc from tblSizes WHERE categoryFK=[cboCategories] ORDER BY SizeDesc
    Then in the Combo2 enter event put

    Combo2.requery

    you may also want to put this code in the current event as well for when you return to the record


    If your form is a datasheet or continuous form then the above will not be sufficient - see this link

    http://www.access-programmers.co.uk/...d.php?t=275155

    the second combo box on the form should be where I would pick the size and be able to edit the quantity
    the above will pick the size, you will need a separate control to edit the quantity

  8. #8
    sprtrmp is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Sep 2015
    Location
    Greenville, SC
    Posts
    102
    I definitely like it, but I have one little issue: I do not want the list of items to show up at the bottom of the form. I guess what I mean is that I want there to be one record available, and ONLY after the "size" selection has been made in the second combo. I don't mean to be picky, but the reason for that is that I don't want the people who will be working with this db to be able to get to ANYTHING that they haven't explicitly navigated to. (we are all barely functioning government employees and I know someone is going to open up the form and immediately start hacking away at the first thing they see). otherwise, the "GOOD" data I feed into this thing is going to last about 10 seconds
    Any ideas? (I know, "some people", right?)

    Another reason for that is that I will need to add and "Add" button at some point that will allow us to make changes when we get new items in, and I want us/me/them to be able to see what they are adding to for clarity purposes. (I should be able to handle the "Add" part though, don't waste your time on that part)

    I seriously appreciate how far you got me though.

  9. #9
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    So these are just demos to help you out.. not trying to design your dB; after all, I know nothing about your requirements.

    How about this??

  10. #10
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Oops, didn't remove enough code.

    Replace
    Code:
    Private Sub cmboSize_AfterUpdate()
        If IsNull(Me.cmboSize) Then
            Me.Filter = "[CategoryID_PK] = " & Me.cmboSelectCat
        Else
            Me.Filter = "[CategoryID_PK] = " & Me.cmboSelectCat & " AND [ProductID_PK] = " & Me.cmboSize
        End If
        Me.FilterOn = True
    End Sub
    with
    Code:
    Private Sub cmboSize_AfterUpdate()
        Me.Filter = "[CategoryID_PK] = " & Me.cmboSelectCat & " AND [ProductID_PK] = " & Me.cmboSize
        Me.FilterOn = True
    End Sub

  11. #11
    sprtrmp is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Sep 2015
    Location
    Greenville, SC
    Posts
    102
    Well, you are doing a whole lot better than I could.

    that works just about perfectly.

    I can't thank you enough!!!

    Mike

  12. #12
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    No problems.


    Ready to mark this solved?

  13. #13
    sprtrmp is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Sep 2015
    Location
    Greenville, SC
    Posts
    102
    Sorry about that, I was so excited to have the thing working, I forgot all about that!

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

Similar Threads

  1. Cascading Combo Boxes Requery Problem
    By Jo22 in forum Forms
    Replies: 9
    Last Post: 01-28-2012, 09:41 AM
  2. Replies: 4
    Last Post: 01-22-2012, 10:48 PM
  3. Sum of Cascading Combo Boxes
    By alonewolf23 in forum Forms
    Replies: 2
    Last Post: 11-20-2011, 02:10 PM
  4. Cascading Combo boxes Problem
    By aamer in forum Access
    Replies: 12
    Last Post: 04-03-2011, 07:11 AM
  5. Problem with Cascading Combo Boxes
    By CushingMT in forum Forms
    Replies: 0
    Last Post: 11-13-2008, 09:44 AM

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