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