Log on Table... Help!!



I am trying to capture the log on/off times for users. I have created a
History table with the fields autoid (autonumber), username, login
time, logout time. I have created a form that has the following VBA
for the Open property. It captures the CurrentUser and the Login time
as now(). The problem I am having is the Log out time. I want the
system to match up the record that has already been created from the
login and just add the Log out time without creating another record,
but to just fill in the Log out Field. I have tried the following
syntax at the Form_Close() propertybut it keeps giving me a syntax
error that the ";" is missing. I have tried putting the ";" literally
everywhere but to no avail.

The syntax for the Form_Close()

Private Sub Form_Close()
Dim sSQL As String
sSQL = "INSERT INTO LogHistory (LogOut) VALUES (now())"
sSQL = sSQL + " where (loghistory.username) = CurrentUser"
DBEngine(0)(0).Execute sSQL


End Sub

The Form_Open() syntax is..

Private Sub Form_Open(Cancel As Integer)
Dim sSQL As String
sSQL = "INSERT INTO LogHistory (UserName,LogIn) VALUES (""" &
CurrentUser & """, now())"
DBEngine(0)(0).Execute sSQL
End Sub



PLEASE HELP!

Thank you!

Sandspirit

.



Relevant Pages

  • Steve Perkins advice!
    ... the syntax SELECT * FROM [tablename] ... Nothing special comes wen i type it into the password and login ID(I ... dint type exactly the same thing since its the syntax, ... Just invalid password or Login appears, ...
    (alt.2600)
  • Re: How user can change their password with sp_password.
    ... Only members of the sysadmin role can change the password ... > for another user?s login. ... > Name' in the sp_password syntax. ... > SQL Server Developer Support Engineer, MCDBA, MCSE, MCT ...
    (microsoft.public.sqlserver.security)
  • Re: Variables in SQL-script SQL2005
    ... Not all DCL commands accept variables (see BOL syntax) so you'll need to use dynamic SQL. ... DECLARE @SqlStatement nvarchar; ... N'CREATE LOGIN ' + ... DECLARE @brugernavn as char ...
    (comp.databases.ms-sqlserver)
  • Re: Linked Server Login Mapping - strange thing...
    ... > using OpenQuery (syntax is correct) ... > Created a mapping on Linked server security: Local Login ... > systems folks than SQL? ...
    (microsoft.public.sqlserver.security)