Results 1 to 3 of 3
  1. #1
    Reaper is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Nov 2011
    Posts
    57

    Error #: 3075 in DLookup

    This code should go to my tblEmployees table and return the value of the txtCurrentAssign field based on the employee name on the form.
    I keep getting Error #: 3075 when it hits the Dlookup line. Seems like I'm missing something but I can't see it.

    Any help appreciated.

    txtTechName - Selected employee name on form
    varAssign - variable to capture result of DLookup
    tblEmployees - employees table
    txtEmployeeName - field in tblEmployees containing the employee's name
    txtCurrentAssign - field in tblEmployees containing the employee's current assignment

    Text in the Error message:

    Error #: 3075

    Syntax error (missing operator) in query expression
    '[txtemployeename]=Test Name.

    ---------------------------------------------------------------------------------------
    Private Sub cmdCheckTech_Click()

    On Error GoTo Err_Handler

    Dim varAssign As Variant

    If IsNull(Me.txtTechName) Then
    MsgBox "Please select Technician name!", vbExclamation
    Else:
    varAssign= Nz(DLookup("[txtcurrentassign]", "[tblemployees]", "[txtemployeename]=" & Me.txtTechName))

    MsgBox varAssign

    ' I'll add more when I get this debugged.

    End If
    Exit Sub

    Err_Handler:
    MsgBox "Error #: " & Err.Number & vbCrLf & vbCrLf & Err.Description, vbCritical, "Click Error"


    Exit Sub

    End Sub
    Attached Thumbnails Attached Thumbnails Error.png  
    Last edited by Reaper; 08-09-2014 at 10:49 AM. Reason: bad attachmnt

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Don't use the : after Else because the code is multi-line.

    What is the value of txtTechName? Is it a number ID or text? Is txtEmployeeName a number ID field or is it text type and the actual employee name? Why don't you search on employee ID?

    Text type fields require apostrophe delimiters around parameters.

    varAssign= Nz(DLookup("[txtcurrentassign]", "[tblemployees]", "[txtemployeename]='" & Me.txtTechName & "'"))
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Reaper is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    Nov 2011
    Posts
    57
    Not sure where the : came from.

    All my variables with txt at the front are text variables. The employee name is coming from a drop down selection and the users wouldn't necessarily know the ID.

    Adding the apostrophes fixed it. Thanks.

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

Similar Threads

  1. Dlookup run-time error '3075'
    By sq75222 in forum Access
    Replies: 5
    Last Post: 08-08-2014, 12:52 PM
  2. Replies: 11
    Last Post: 05-01-2014, 11:56 AM
  3. DLookup Error 3075
    By healey33 in forum Access
    Replies: 2
    Last Post: 05-21-2013, 10:05 AM
  4. Replies: 5
    Last Post: 09-05-2012, 09:28 AM
  5. Replies: 6
    Last Post: 05-30-2012, 12:32 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