I get this error message when running this code and it fails on the DLookup line.
Here is the full code:
fosusername() pulls the windows userid I am logged in with. I simply want the user to click a button and it will log the empid from the employees table into the emp# field in the timeworked table.
THis is what the table looks like. So worries no sensitive info here
. As you can see the first record has the information I need.
Tbl_TK_EmployeeEmpIDEmpFNameEmpLNameEmpUserIDEmpAccessLvlABD100001GUNTHERWILLIAMSgwill23AdminABD100002STEVEBARELAsteveMangerABD100003GAILWILLIAMSgailSuperABD100004ANTHONYWILLIAMSwillEmployeeABD100006SUSANBRUST
NoneABD100008DEBORAHHUGHES
NoneABD100009PETERNORTHCUTT
NoneABD100011SETHROBERTS
NoneABD100012RANDALLLADMAN
NoneABD100016KIMBRANDON
NoneABD100017ALICEPENDERGRASS
None
Any ideas?
rs!Emp# = DLookup("[EmpID]", "Tbl_TK_Employee", "[EmpUserID] = '" & UserID & "'")
Here is the full code:
Private Sub ClockIn_Click()
Dim rs As New ADODB.Recordset
Dim UserID As String
UserID = fOSUserName()
rs.Open "tbl_TK_TimeWorked", CurrentProject.Connection, adOpenDynamic, adLockOptimistic
rs.AddNew
rs!Emp# = DLookup("[EmpID]", "Tbl_TK_Employee", "[EmpUserID] = '" & UserID & "'")
rs!Date = Now()
rs!StartTime = Now()
rs!Task = DLookup("[id]", "Tbl_TK_TaskList", "[task] = Clocked In")
rs.Update
rs.Close
Set rs = Nothing
End Sub
fosusername() pulls the windows userid I am logged in with. I simply want the user to click a button and it will log the empid from the employees table into the emp# field in the timeworked table.
THis is what the table looks like. So worries no sensitive info here

Tbl_TK_EmployeeEmpIDEmpFNameEmpLNameEmpUserIDEmpAccessLvlABD100001GUNTHERWILLIAMSgwill23AdminABD100002STEVEBARELAsteveMangerABD100003GAILWILLIAMSgailSuperABD100004ANTHONYWILLIAMSwillEmployeeABD100006SUSANBRUST
NoneABD100008DEBORAHHUGHES
NoneABD100009PETERNORTHCUTT
NoneABD100011SETHROBERTS
NoneABD100012RANDALLLADMAN
NoneABD100016KIMBRANDON
NoneABD100017ALICEPENDERGRASS
None
Any ideas?