Did you see the code in post #2?
You haven't added "Option Explicit" yet. This is important.
Here is the code again:
Code:
Sub Command14_Click()
Dim pvUser As String
Dim User_Name As String
Dim sSql As String
If CLng(Me.Text3) = DLookup("[Code_Number]", "User_List", "[Code_number] = " & CLng(Me.Text3)) Then
' pvUser = Environ("UserName")
'uncomment the next line if you want to store the user name from the table "User_list"
'And comment out the above line that has the Environ command
pvUser = DLookup("[Code_Number]", "User_List", "[Code_number] = " & CLng(Me.Text3))
sSql = "INSERT INTO tLogs ([Event],[USER],[EntryDate]) VALUES ('" & Me.Text3 & "', '" & pvUser & "',#" & Now() & "#)"
' Debug.Print sSql
CurrentDb.Execute sSql, dbFailOnError ' <- I also corrected this. You had dbFailOn
'user accepted..start form
DoCmd.OpenForm "Worker_Console"
DoCmd.Close acForm, "User_Entry"
End If
End Sub