Results 1 to 2 of 2
  1. #1
    pillaisg is offline Novice
    Windows 10 Access 2016
    Join Date
    Dec 2023
    Posts
    2

    Subforms based on selections on comboboxes

    This line was added for having a blank selection in the combo box
    cmb_PID_Inst_Type= " " (highlighted in Red)

    But the sub form is not getting populated with the relevant data. (Subform query snap attached)
    The requirement is based on selection in Ref_Type all records matching the criteria shall be appearing on the subform and further upon selection of PID_Inst_Type only records matching with Ref_Type and PID_Inst_Type shall be displayed .. like wise Installation_Type shall show all records in Subform based on selection on Ref_Type, PID_Inst_Type and Installation_Type.

    The following is the code I had used. Any suggestion or observations on the below is appreciated.

    Private Sub Form_Load()
    Cmb_Enquiry_No.RowSourceType = "Table/Query"
    Cmb_Enquiry_No.RowSource = "Select Distinct Enquiry_No from T_master_pid"
    Cmb_Ref_No.RowSourceType = "Table/Query"
    Cmb_Ref_No.RowSource = "Select Distinct Ref_No from T_master_pid"
    Cmb_Ref_Type.RowSourceType = "Table/Query"
    Cmb_Ref_Type.RowSource = "Select Distinct Ref_Type from T_master_pid"
    Cmb_PID_Inst_Type.RowSourceType = "Table/Query"
    Cmb_PID_Inst_Type = " "
    Cmb_PID_Inst_Type.RowSource = "Select Distinct PID_Inst_Type from T_master_pid"
    Cmb_Installation_Type.RowSourceType = "Table/Query"


    Cmb_Installation_Type.RowSource = "Select Distinct Installation_Type from T_master_pid"

    End Sub

  2. #2
    davegri's Avatar
    davegri is offline Excess Access
    Windows 11 Access 2019
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,413
    You want cascading combo boxes. See
    Ultimate Dynamic Multiple Cascading Comboboxes, synchronized in any order (accessforums.net)

    The example if for a main form but code logic is easily adapted for a subform.
    The last line in procedure ProcessAllCombos should be changed to:


    Me.ControlnameHoldingSubform.Form.Recordsource = "Select * From YourTable " & strRSWhere


    Change ControlnameHoldingSubform and YourTable to names appropriate for your DB.
    Last edited by davegri; 12-16-2023 at 07:41 AM. Reason: Added change advice

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

Similar Threads

  1. Replies: 29
    Last Post: 11-09-2020, 05:12 AM
  2. Replies: 17
    Last Post: 04-29-2015, 11:48 AM
  3. Replies: 1
    Last Post: 12-09-2012, 05:27 PM
  4. Selections based off of tiered criteria
    By New_2_Access in forum Access
    Replies: 7
    Last Post: 06-19-2012, 11:00 PM
  5. open form based on comboboxes
    By bigmac in forum Forms
    Replies: 1
    Last Post: 04-04-2012, 06:55 AM

Tags for this Thread

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