Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2015
    Posts
    1

    Angry Answered: DLookup is returning #Name or #Error

    I’m trying to get a text box on a form to display a particular value using DLookup.

    The table is “tblEmployee” and it has only two fields “Employee Name” and “Employee ID Number”.

    There are two forms “frmMain” and “frmViewrecord”.

    “frmMain” has a combo box with all the records of the “Employee Name” field. When a name is selected from the combo box and a button is clicked “frmViewrecord” opens.

    “frmViewrecord” has two text boxes “txt47” and “txt49”.

    “txt47” displays the Name that was selected in the Combo box.

    This is where I run into trouble: I want “txt 49” to display the Employee ID Number that correlates with the name selected in the combo box.

    I’ve been using different DLookup formats from around the web but all either return “#Name” or “#Error” in “txt 49” when I switch “frmViewrecord” from design to form view. Here is the syntax I’ve been trying.

    DLookup("FieldName", "TableName", "Criteria = " & forms!FormName!ControlName

    =DLookup("Employee ID Number", "tblEmployee", "Employee Name = " & forms!frmMain!comboNames)

    Please Help!

  2. Best Answer
    Posted by pbaldy

    "Oh, and if the criteria is a text field, you'd need delimiters:

    http://www.mvps.org/access/general/gen0018.htm

    But the link is more efficient."


  3. #2
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    The names with inadvisable spaces need to be bracketed. You may find this easier and more efficient:

    http://www.baldyweb.com/Autofill.htm
    Paul

  4. #3
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Oh, and if the criteria is a text field, you'd need delimiters:

    http://www.mvps.org/access/general/gen0018.htm

    But the link is more efficient.
    Paul

Tags for this Thread

Posting Permissions

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