Results 1 to 5 of 5
  1. #1
    cbrxxrider is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2013
    Location
    Central NY
    Posts
    16

    Combo box list based on another combo and vice vera back

    I have two combo boxes department and employee. I had it set up so that the user would select the department and only those employees within that department would show in the second combo. So for example, user selects IT and only those employees within IT are listed in the second combo box.

    I put this in the employee combo.

    SELECT Employee.EmployeeID, Employee.[First Name],
    Employee.[Last Name], Department.Department
    FROM Department INNER JOIN


    Employee ON Department.Department = Employee.Department
    WHERE
    (((Employee.[Manager/Supervisor])=No))
    ORDER BY Employee.[First
    Name];

    If the user does not know the department but the employees name I would like for them to have the option to choose the employee name first and
    then the department combo selects the correct department or at least only shows that in the list.

    So I thought it was basically just the opposite... I put this in the department combo.

    SELECT Department.Department
    FROM
    Department INNER JOIN Employee ON Department.Department =
    Employee.Department
    WHERE
    (((Employee.EmployeeID)=[forms]![CompletedGoalForm]![EmployeeID]));

    Now this allows the user to select the employee first and the department combo lists the department to click on.

    The problem now is the department combo is blank unless an employee is chosen. The user can no longer choose a department first and then have the employees under that department listed.

    Any
    ideas?

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    I don't know if a circular dependency like this can work at all, but try LIKE operator with wildcard.

    WHERE
    (((Employee.EmployeeID) LIKE [forms]![CompletedGoalForm]![EmployeeID] & "*"));
    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
    cbrxxrider is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2013
    Location
    Central NY
    Posts
    16
    Quote Originally Posted by June7 View Post
    I don't know if a circular dependency like this can work at all, but try LIKE operator with wildcard.

    WHERE
    (((Employee.EmployeeID) LIKE [forms]![CompletedGoalForm]![EmployeeID] & "*"));
    Thanks, it almost worked, unfortunately it listed all the departments multiple times, 1 for each employee listed in the second combo box. Maybe I can play with it further off what you said and get it to kill the duplicates.

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    Why don't you use an if then statement to see if the other combobox is empty? If there is not a value in the other combox then rowsource = A else rowsource = B

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Does this help:

    SELECT DISTINCT Department.Department ...
    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.

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

Similar Threads

  1. Replies: 2
    Last Post: 09-24-2013, 11:38 AM
  2. Replies: 1
    Last Post: 10-03-2012, 04:12 PM
  3. Replies: 5
    Last Post: 08-30-2012, 06:34 PM
  4. list box based on combo box
    By crowegreg in forum Forms
    Replies: 8
    Last Post: 08-08-2012, 09:45 AM
  5. Replies: 1
    Last Post: 02-03-2012, 03:51 PM

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