Results 1 to 3 of 3
  1. #1
    Wombat is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2012
    Posts
    33

    Dlookup

    I want to fill a textbox with the hiredate of an employee

    Dim Hdate As Date
    Hdate = DLookup("[HireDate]", "Employee", "Employee.EmployeeID = " & Forms!frm_EmployeeInformation.EmployeeID)

    Gives me the error:
    Run-time error '3075':
    Syntax error (missing operator) in query expression
    Employee.EmployeeID = 55BBBBBBBB

    that 55BBBBBBBB is the sample employee number that I put in there, so I don't understand why it's not working.



    The field is set to text but the error changes if it is all numbers or all letters.

  2. #2
    irish634 is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Feb 2012
    Posts
    48
    Hdate = DLookup("[HireDate]", "Employee", "Employee.EmployeeID= " & Forms!frm_EmployeeInformation.EmployeeID)

    Take the space out after employee id.

  3. #3
    Wombat is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2012
    Posts
    33
    That wasn't it, but I figured it out.

    if you use a text criteria in your dlookup "where" clause you must put the text value in single quotes:
    Hdate = DLookup("[HireDate]", "Employee", "Employee.EmployeeID = '" & Forms!frm_EmployeeInformation.EmployeeID & "'")

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

Similar Threads

  1. dlookup
    By ali zaib in forum Access
    Replies: 3
    Last Post: 01-13-2012, 11:57 AM
  2. Dlookup
    By cbrsix in forum Forms
    Replies: 2
    Last Post: 11-01-2011, 02:59 PM
  3. Dlookup
    By cbrsix in forum Forms
    Replies: 6
    Last Post: 11-01-2011, 10:38 AM
  4. DLookup
    By smidgey in forum Forms
    Replies: 13
    Last Post: 01-19-2011, 09:27 AM
  5. Need help with dlookup.
    By Keith in forum Database Design
    Replies: 8
    Last Post: 05-24-2010, 06:28 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