In Access 2007, I'm trying to use the NTlogin to retrieve a value from a table via a SQL query (see code below). WHen the form loads, I get an error message saying "Compile Error: Expected Function or Variable". Can someone tell me how to fix this error.
Private Sub Form_Load()
Dim UserName As String
Dim strSQL As String
Dim strDept As String
UserName = Environ("USERNAME")
strSQL = "SELECT DEPT FROM IDs WHERE NTLOGIN =" & UserName
strDept = DoCmd.RunSQL(strSQL)
cmdSave.Enabled = False
cmdEdit.Enabled = True
cmdPrevious.Enabled = True
cmdNext.Enabled = True
End Sub