Results 1 to 4 of 4
  1. #1
    tylerg11 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Sep 2011
    Posts
    200

    DLookup() for Text Box Control Source


    I am trying to make the Control Source for a textbox a lookup function. I don't understand why it isn't working...

    =DLookUp("[EmployeeFirstName]","dbo_EmployeeNumber","[EmployeeNumber]= '" & [Me]![CONTACTLOCATION_ENTEREDBY_QCEMPLOYEE_ID] & "'")

  2. #2
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    Is EmployeeNumber Text or a numeric field type?

    If numeric, get rid of the quotes and you can't use ME in a control source. So if it is numeric and not a text field it would be:

    =DLookUp("[EmployeeFirstName]","dbo_EmployeeNumber","[EmployeeNumber]= " & [CONTACTLOCATION_ENTEREDBY_QCEMPLOYEE_ID])

  3. #3
    tylerg11 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Sep 2011
    Posts
    200
    Perfect! That works.

    I thought that you needed the ' when it is a numeric data type...the same as a WHERE clause for SQL.

  4. #4
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    Quote Originally Posted by tylerg11 View Post

    I thought that you needed the ' when it is a numeric data type...the same as a WHERE clause for SQL.
    Nope, in Access you want NONE of them when using numeric data types, and quotes when using Text and the Octothorpes (#) when using dates.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 13
    Last Post: 01-11-2012, 09:44 PM
  2. Dlookup as Control Source
    By alsoto in forum Forms
    Replies: 1
    Last Post: 08-28-2011, 07:05 PM
  3. IIF statement in control source of text box
    By LilMissAttack in forum Reports
    Replies: 11
    Last Post: 08-18-2011, 10:02 PM
  4. Control Source for Text Box (#error)
    By km8415 in forum Forms
    Replies: 3
    Last Post: 06-27-2010, 10:45 AM
  5. Replies: 1
    Last Post: 04-29-2010, 05:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums - Senior Forums