Results 1 to 2 of 2
  1. #1
    sra2786 is offline Advanced Beginner
    Windows 7 64bit Access 2016
    Join Date
    Oct 2017
    Location
    Cincinnati, OH
    Posts
    38

    Combo boxes dependent on each other

    I have two Combo boxes -- one for Material Number and one for Material Text. The user can select from only one Combo Box and the other Combo Box will be populated based on the selected value. If I select from the Material Text combo box, the correct value is displayed in Material Number ... but if I select from the Material Number combo box, no value is displayed in Material Text.

    The RowSource is the same for both Combo Boxes
    SELECT DISTINCT tblSubAssemblyInfo.ParentAssemblyID, tblPartMain.PartDescription
    FROM tblSubAssemblyInfo INNER JOIN tblPartMain ON tblSubAssemblyInfo.ParentAssemblyID = tblPartMain.MfrPartNumber
    WHERE (((tblSubAssemblyInfo.Plant)=[Forms]![frmExpandAssembly]![cboPlant]));

    For Material Number, the Column Widths = 1";0"
    For Material Text, the Column Widths = 0";1"



    Private Sub cboMaterial_AfterUpdate()


    Me.cboText = Me.cboMaterial.Column(1)
    Me.cboText.Requery
    End Sub


    Private Sub cboText_AfterUpdate()
    Me.cboMaterial = Me.cboText.Column(0)
    Me.cboMaterial.Requery
    End Sub

    I am not sure what I am doing wrong.
    Thanks.
    Sandy

  2. #2
    Micron is online now Very Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,423
    You could research 'cascading' combo boxes (because there's literally thousands of web pages on this) or try fixing your row sources for the combos (they are not bound, correct?).
    Whichever is the 'child' gets filtered by a value chosen in the parent - they cannot be retrieving the same data (cannot have the same row source). If user drops down the child when there's no parent value chosen, there should be no list. The AfterUpdate event of the parent is used to requery the child so that any change to the parent resets the child.

    It doesn't look to me like you have the correct sql for either box, but not sure without seeing the data. If cmb1 values are in one table and cmb2 values are in another table, there's no need to join them for either combo, based on my interpretation of your tables. Try creating select queries for each, where the child sql displays what you want according to the value chosen by the parent, then set each combo's row source to the applicable query or sql statement.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Replies: 2
    Last Post: 05-29-2015, 09:21 AM
  2. dependent combo boxes
    By jle0003 in forum Forms
    Replies: 3
    Last Post: 10-03-2012, 02:23 PM
  3. Multiple dependent combo boxes
    By anunat in forum Forms
    Replies: 15
    Last Post: 07-09-2012, 03:09 PM
  4. Dependent Combo Boxes
    By schwabe in forum Forms
    Replies: 3
    Last Post: 01-09-2012, 04:33 PM
  5. Combo Boxes with dependent queries
    By K Roger in forum Access
    Replies: 3
    Last Post: 09-27-2011, 11:58 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