Results 1 to 2 of 2
  1. #1
    heinensk23 is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2011
    Posts
    13

    Subform that filters on combination of 2 combo boxes

    I have a form that uses cascading combo boxes to filter on a subform.
    Menu Group is the first box and Menu Item choices are based on what is chosen in Menu Group.
    However, there are some menu items that show up in multiple Menu Groups.

    Right now the subform only filters on the Menu Item.
    I need it to filter on both Menu Group field and Menu Item field.

    Here is the code:

    Private Sub casc_cmbo_BRASS_Menu_Group_AfterUpdate()


    Me!casc_cmbo_BRASS_Menu_Item.RowSource = Me!casc_cmbo_BRASS_Menu_Item.RowSource
    Me!casc_cmbo_BRASS_Menu_Item = Null


    End Sub


    Private Sub casc_cmbo_BRASS_Menu_Item_AfterUpdate()


    Dim myCascmenuitem As String
    myCascmenuitem = "Select * from tbl_BRASS_Item_Setup where [Menu_Item_Toast_Name] = '" & Me.casc_cmbo_BRASS_Menu_Item & "'"
    Me.subfrm_BRASS_ITEM_SETUP_subform.Form.RecordSour ce = myCascmenuitem


    Me.subfrm_BRASS_ITEM_SETUP_subform.Form.Requery


    End Sub

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    Try:
    Code:
    Dim myCascmenuitem As String
       myCascmenuitem = "Select * from tbl_BRASS_Item_Setup where [Menu_Item_Toast_Name] = '" & Me.casc_cmbo_BRASS_Menu_Item & "' AND [SecondFieldName] = '" & Me.NameOfSecondCombo & "'"
       Me.subfrm_BRASS_ITEM_SETUP_subform.Form.RecordSour ce = myCascmenuitem
       Me.subfrm_BRASS_ITEM_SETUP_subform.Form.Requery
    Substitute your real names for those shown in blue.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

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

Similar Threads

  1. Replies: 4
    Last Post: 06-06-2017, 04:26 AM
  2. Replies: 8
    Last Post: 10-18-2015, 10:44 PM
  3. Filter subform with two combo boxes
    By dotcanada in forum Forms
    Replies: 4
    Last Post: 07-25-2015, 05:20 PM
  4. Subform and combo boxes
    By paramesium in forum Forms
    Replies: 5
    Last Post: 02-17-2014, 03:35 AM
  5. Replies: 14
    Last Post: 02-09-2012, 08:33 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