Filtered and Multiple Lookups

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JacqStar
    New Member
    • Oct 2008
    • 1

    #1

    Filtered and Multiple Lookups

    I'm really not very good at access, so this will probably be a sinch for most of you

    I have a form with one of the inputs as a lookup. For the sake of an explanation I'll call this lookup the "Department " field

    I would then like the next two lookups to look to a table which contains Employee first and last names, for example and the departments which they belong to. I would like the lookup to only show the fields of people who belong to the department which has already been chosen by the first lookup, and then by making only one selection, put two different values (first and last name) in two different columns.

    If anyone can help a beginner it would be great!!!
  • puppydogbuddy
    Recognized Expert Top Contributor
    • May 2007
    • 1923

    #2
    Originally posted by JacqStar
    I'm really not very good at access, so this will probably be a sinch for most of you

    I have a form with one of the inputs as a lookup. For the sake of an explanation I'll call this lookup the "Department " field

    I would then like the next two lookups to look to a table which contains Employee first and last names, for example and the departments which they belong to. I would like the lookup to only show the fields of people who belong to the department which has already been chosen by the first lookup, and then by making only one selection, put two different values (first and last name) in two different columns.

    If anyone can help a beginner it would be great!!!
    See if this is what you wanted.

    Tables>Dept, Employee
    Lookups are comboboxes >cboDept, cboEmployee

    Assumes that DeptNo and EmployeeNo are both text data types

    cboDept>DeptAut onumber(Bound Column(0)-Hidden), DeptNo, DeptName

    Code:
    cboDept.RowSource = "Select * From Dept"
    cboEmployee>Emp lAutonumber(Bou nd Column(0) Hidden), EmployeeID, FirstName, LastName, DeptNo

    Code:
    cboEmployee.RowSource = "Select * From Employee Where DeptNo = '" & Me!cboDept.Column(1) & "'"

    Code:
    Private Sub cboEmployee_AfterUpdate()
    cboEmployee.RowSource = "Select * From Employee Where  EmployeeID = '" & Me!cboEmployee.Column(1) & "'"
    Me!txtFirstName.Value = cboEmployee.Column(2)
    Me!txtLastName.Value =  cboEmployee.Column(3)
    End Sub

    Comment

    Working...