Lookup table

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ielamrani
    New Member
    • Feb 2007
    • 72

    Lookup table

    Hi everyone,
    I have a form with 2 text boxes linked to a table (table1). One is a drop
    down box (DB1)to select user and one is text box (T1)to enter Department.
    table1 has 2 fields: Name and Dept. I would like the department to be
    entered based the name selected.

    table1:
    Code:
    Name                              Dept
    Ish                                  NB
    John                               BC
    Bob                                NB
    In the form if I select the name of Ish in the drop down (DB1) then The tex
    box (T1)should show NB..If I select John then BC show..etc

    Right now I am doing the following:
    Code:
    Private Sub DB1_AfterUpdate()
    If Me.DB1 = "Ish" Or Me.DB1 = "Bob" Then
    Me.T1= "NB"
    Else 
    Me.T1 = "BC"
    End If
    If this is not clear please let me know. and Thanks is advance.
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32662

    #2
    As a full member now, you should know that we expect your code to be posted in [CODE] tags (See How to Ask a Question).
    This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.
    Please use the tags in future.

    ADMIN.

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32662

      #3
      What you need to do is have a multi-column ComboBox control.

      If you still feel you need the department displayed in a separate TextBox control then that can be handled with an AfterUpdate procedure on the ComboBox.

      Comment

      Working...