using FindFirst

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi
I have a table which will track who logs in and out including the date.

I was able to add the username and date & time they have logged in but I
would like to do a find the username and the empty log out date field to be
able to enter the date and time they are logging out.

All of this is done through a auto exe form.

Thanks
Noemi
 
I would use an update query to do this.

UPDATE [LogTable]
Set [LogoutTime] = Now()
WHERE [UserID] = "TheUserID" and [LogoutTime] is Null

Since you gave us no real details on how you are doing this I don't have
much further in terms of suggestions.

If I were doing this I would have an always open form (probably with its
visibility property set to false). Then in the form's close event (which
will happen whenever the database is closed), I would include code to
execute the update. If you have a routine that gets the user's login name
then

Something like the following
Private Sub Form_Close()
Dim strSQL As String
Dim strUserID As String

'fosUserName is custom vba function that returns the current user
'use whatever you have to get the user name
strUserID = fosusername()

strSQL = "UPDATE [LogTable]" & _
" Set [Logout] = Now()" & _
" WHERE [Logout] is Null and UserID = """ & strUserID & """"
CurrentDb().Execute strSQL

End Sub

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 
Hi John
Thank you so much.
I do have the hidden form but I didn't know how to get teh logout date to
work.
Thanks for your help.

Noemi

John Spencer said:
I would use an update query to do this.

UPDATE [LogTable]
Set [LogoutTime] = Now()
WHERE [UserID] = "TheUserID" and [LogoutTime] is Null

Since you gave us no real details on how you are doing this I don't have
much further in terms of suggestions.

If I were doing this I would have an always open form (probably with its
visibility property set to false). Then in the form's close event (which
will happen whenever the database is closed), I would include code to
execute the update. If you have a routine that gets the user's login name
then

Something like the following
Private Sub Form_Close()
Dim strSQL As String
Dim strUserID As String

'fosUserName is custom vba function that returns the current user
'use whatever you have to get the user name
strUserID = fosusername()

strSQL = "UPDATE [LogTable]" & _
" Set [Logout] = Now()" & _
" WHERE [Logout] is Null and UserID = """ & strUserID & """"
CurrentDb().Execute strSQL

End Sub

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..

Noemi said:
Hi
I have a table which will track who logs in and out including the date.

I was able to add the username and date & time they have logged in but I
would like to do a find the username and the empty log out date field to
be
able to enter the date and time they are logging out.

All of this is done through a auto exe form.

Thanks
Noemi
 
Back
Top