R
Rhys Davies
Hi - when a users logs in the following code runs in my system:
DoCmd.SetWarnings False
strsql = "INSERT INTO tblusersloggedin([userID],[loggedindatetime],[user])"
& _
"SELECT" & "'" & useridno & "'," & _
"'" & Now & "', " & _
"'" & loginname & "'"
DoCmd.RunSQL strsql
DoCmd.SetWarnings True
this is fine because it enters the users unique ID number, loginname and
time/date into the table so that i can see who logged in when.
However, i now want to add similar code on the close command button that
will insert the date/time that the user logged off.
The code i have is:
Dim strsql As String
strsql = "INSERT INTO tblusersloggedin([loggedoffdatetime])" & _
"SELECT" & "'" & Now & "'" & _
"WHERE tblusersloggedin([user]) = '" & loginname & "'"
DoCmd.RunSQL strsql
i am using the WHERE clause to match the value in the user field in table
'tblusersloggedin' with their loginname so that the log off time/date will be
entered against the correct user. loginname is a global variable that
persists while they are logged into the system.
However access doesnt like my syntax, keeps saying that there is a missing
expression - can anyone help?
Thanks,
Rhys.
DoCmd.SetWarnings False
strsql = "INSERT INTO tblusersloggedin([userID],[loggedindatetime],[user])"
& _
"SELECT" & "'" & useridno & "'," & _
"'" & Now & "', " & _
"'" & loginname & "'"
DoCmd.RunSQL strsql
DoCmd.SetWarnings True
this is fine because it enters the users unique ID number, loginname and
time/date into the table so that i can see who logged in when.
However, i now want to add similar code on the close command button that
will insert the date/time that the user logged off.
The code i have is:
Dim strsql As String
strsql = "INSERT INTO tblusersloggedin([loggedoffdatetime])" & _
"SELECT" & "'" & Now & "'" & _
"WHERE tblusersloggedin([user]) = '" & loginname & "'"
DoCmd.RunSQL strsql
i am using the WHERE clause to match the value in the user field in table
'tblusersloggedin' with their loginname so that the log off time/date will be
entered against the correct user. loginname is a global variable that
persists while they are logged into the system.
However access doesnt like my syntax, keeps saying that there is a missing
expression - can anyone help?
Thanks,
Rhys.