Results 1 to 5 of 5
  1. #1
    2 Star Lounger
    Join Date
    Jul 2003
    Location
    Cincinnati, Ohio
    Posts
    107
    Thanks
    0
    Thanked 0 Times in 0 Posts

    dlookup syntax help (2003)

    I am trying to get dlookup to display an employee's department in a text box (txtDisplayDepartment) when their name is selected from a combo box. The form name is frmImpactedCommunity. The combo box is cmbStaffName (control source = staffnameID) . tblStaff has a staffnameID field and a DepartmentID field to relate to tblDepartment (holding department info...Accounting, HR, etc....the field I would like to display is "department"). I have tried the following as the control source for txtDisplayDepartment and cannot get it to work (I receive #name?) when displayed. =LookUp "[Department]","tblDepartment","[StaffNameID]"=tblStaff.StaffNameID). Any help would be appreciated and is dlookup the best way to accomplish this? Thank you for your help....Scott

  2. #2
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Alzano Lombardo, Italy
    Posts
    1,483
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: dlookup syntax help (2003)

    Hi,
    the correct syntax should be:
    =DLookUp("Department","tblDepartment","StaffNameID =" & tblStaff.cmbStaffName)
    but you can also put the controlsource of the txtDisplayDepartment text box equal to cmbStaffName.

  3. #3
    2 Star Lounger
    Join Date
    Jul 2003
    Location
    Cincinnati, Ohio
    Posts
    107
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: dlookup syntax help (2003)

    Thank you for your help. I'm still getting the #name error. I have attached screen shots in a word file that may show what I'm doing wrong. Thanks again for your help.

  4. #4
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Alzano Lombardo, Italy
    Posts
    1,483
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: dlookup syntax help (2003)

    First you have to add the DepartmentID field to the cmbStaffName control source, use the DepartmentID as the bound column and then use
    =DLookUp("Department","tblDepartment","DepartmentI D=" & forms!frmImpactedCommunity.cmbStaffName)
    as the txtDisplayDepartment text box control source

  5. #5
    2 Star Lounger
    Join Date
    Jul 2003
    Location
    Cincinnati, Ohio
    Posts
    107
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: dlookup syntax help (2003)

    That did it. Thank you again for your help!

Posting Permissions

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