Results 1 to 5 of 5
  1. #1
    Eranka is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Dec 2017
    Posts
    150

    Combo Box Selection

    Hi



    I have created two combo boxes in my access form.

    Combobox1 = Employee_ID (Employee Table)
    Combobox2 = Employee_Working_Department (Department table)

    When i click on the 1st combobox and select an employee the second combo box should show the departments that he working. (If an employee works in IT and HR the second combo should show only IT and HR). How to do this?

    ***With my current form when i select an employee it shows all the department in the company instead of showing IT and HR***

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    The form should be connected to Employee table,
    there should be a text box connected to EmpID field, (and all other Employee fields)
    the form header should have an unbound combo box with the EmpIDs to filter

    once you pick combo EmpID, filter the record to show that 1 employee. The combo box will filter too.
    Code:
    sub cboEmpID_afterupdate()
    if isNull(cboEmpID) then
       me.filterOn = false
    else
       me.filter = "[EmpID]=" & cboEmpID 
       me.filterOn = true
    end if
    end sub

  3. #3
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    The Row Source for Combobox2 should have a WHERE condition that references Combobox1 and a little VBA code to requery.

    Tear apart the attached example dB.
    IIRC, it has 7 cascading combo boxes.

    Also, there is a cascading list box example (to see all options at once).
    Attached Files Attached Files

  4. #4
    Eranka is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Dec 2017
    Posts
    150
    Hi ssanfu

    How did you hide the tables and forms on the side and display the main menu when program opens?

  5. #5
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,204
    As I'm online, I'll answer for ssanfu.

    Go to File ...Options ... Current Database
    The 2 items I've highlighted load a specified form & hide the navigation pane

    Click image for larger version. 

Name:	Capture.PNG 
Views:	16 
Size:	41.8 KB 
ID:	31851

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

Similar Threads

  1. Replies: 5
    Last Post: 05-31-2017, 08:58 AM
  2. Replies: 7
    Last Post: 03-30-2015, 10:04 AM
  3. Replies: 5
    Last Post: 04-09-2014, 06:57 PM
  4. Replies: 3
    Last Post: 07-03-2013, 10:38 AM
  5. Replies: 1
    Last Post: 10-30-2012, 10:29 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