Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2012
    Posts
    31

    Answered: Linking subforms and combo boxes

    Hello there,
    I need some help setting a form up which uses two combo boxes and one subform.

    I need to be able to select an employee from the employee (1st combo box)
    The second comobox called department should only list the departments associated with that employee named in the first combo box.
    When a selection is made from the departments combo box, the associated competences and awarded score (all of which is associated to the employee named in the first combo box) appears in the sub form.

    I think I have linked the tables correctly to explicitly tell access how the data all relates. In the attached database the form called employees sort of shows what I am after.

    Any help/tips would be great
    Attached Files Attached Files

  2. Best Answer
    Posted by ranman256

    "To do the multi-combo box
    each combo box has a query for its recordsource.
    Here the user picks a state, then in the next combo picks a Company (in that state)

    The 1st combo,(say cboStates)... User picks a state, then picks a company from the cboCo box.
    The cboStates AfterUpdate event will trigger when the user picks it, and this will update the next combo.


    Code:
    sub cboStates_AfterEvent()
     cboCo.requery
    end sub

    The cboCo query (say qsCoViaState) will reference the cboStates in the query sql
    Select * from tCompany where [ST] ='" & forms!frmMain!cboStates & "'"

    The CO combo must be refreshed (cboCo.requery action) after user picks the state so it can deliver the resulting dataset.

    If there is another combo after this say cboEmps to pick employees, then the cboEmp must be refreshed after user picks cboCo.
    Code:
    sub cboCo_AfterEvent()
     cboEmps.requery
    end sub
    Once you select the Dept, filter the subform on that combo box."


  3. #2
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    496
    Provided Answers: 24
    To do the multi-combo box
    each combo box has a query for its recordsource.
    Here the user picks a state, then in the next combo picks a Company (in that state)

    The 1st combo,(say cboStates)... User picks a state, then picks a company from the cboCo box.
    The cboStates AfterUpdate event will trigger when the user picks it, and this will update the next combo.


    Code:
    sub cboStates_AfterEvent()
     cboCo.requery
    end sub

    The cboCo query (say qsCoViaState) will reference the cboStates in the query sql
    Select * from tCompany where [ST] ='" & forms!frmMain!cboStates & "'"

    The CO combo must be refreshed (cboCo.requery action) after user picks the state so it can deliver the resulting dataset.

    If there is another combo after this say cboEmps to pick employees, then the cboEmp must be refreshed after user picks cboCo.
    Code:
    sub cboCo_AfterEvent()
     cboEmps.requery
    end sub
    Once you select the Dept, filter the subform on that combo box.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •