Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2004
    Posts
    10

    Unanswered: DLookUp Question

    I have a combo box set up to pull an person's name from a table and then place it in another. Works fine.

    How do I get corresponding text boxes to show data based upon the persons name that is selected?

    For example, you select Smith from the combo box and the box next to it should automatically show his file number.

    I am currently using
    Code:
    =DLookUp("[emlname]","employees","[servernumber] = " & [servernumber])
    emlname is the name of the combobox and the name of the field on the table that has the employee's name.

    employees is my table name

    servernumber is the name of the field on the table that I want to match emlname. It is also the name of the field on the form.

    As it is right now I get "#Error"

  2. #2
    Join Date
    Jun 2004
    Posts
    10
    Figured it out...
    =dlookup("servernumber","employees","emlname='" & emlname & "'")

    But, I have a second one that goes.

    =dlookup("servernumber","employees","emlname2='" & emlname2 & "'")

    and it only returns the 1st server number and not the correct one.

    Any suggestions?


  3. #3
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    gosh: it's been a busy day for string concatenation!!!!!

    dlookup ("this", "that", "textfield = '" & yourBox & "'")
    dlookup ("this", "that", "datefield = #" & yourBox & "#")
    dlookup ("this", "that", "numericfield = " & yourBox)

    izy
    currently using SS 2008R2

  4. #4
    Join Date
    Feb 2004
    Location
    New Zealand
    Posts
    1,420
    Provided Answers: 7
    Or
    as the data is in a table why not rewrite right the RowSource of Combo box and show the data but in the Column Width set to 0

    then just call that Column Number in teh AfterUpdate Event

    servernumber = combobox1.Column(??) ?? = the coloumn number

    I find this way quicker as The combo box have been build no need to keep DLOOKUP your data for each new item
    hope this help

    See clear as mud


    StePhan McKillen
    the aim is store once, not store multiple times
    Remember... Optimize 'til you die!
    Progaming environment:
    Access based on my own environment: DAO3.6/A97/A2000/A2003/A2007/A2010
    VB based on my own environment: vb6 sp5
    ASP based on my own environment: 5.6
    VB-NET based on my own environment started 2007
    SQL-2005 based on my own environment started 2008
    MYLE
    YOUR PASSWORD IS JUST LIKE YOUR TOOTHBRUSH DON'T SHARE IT.

Posting Permissions

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