"Omey Samaroo" <no****@replytogroup.com> wrote in message news:<N6*********************@twister01.bloor.is.n et.cable.rogers.com>...
Awesome, thanks for the suggestions Pieter. I will admit that some of it is
a little over my head, but I will do some research and ask more questions if
I get stuck.
Omey
Okay, the stuff from MS...
http://support.microsoft.com/default...B;en-us;128814
Sub IdleTimeDetected (ExpiredMinutes)
Application.Quit acSaveYes
End Sub
You'd just tweak this...
Sub IdleTimeDetected (ExpiredMinutes)
'See below for code...
Call LogKickOut
Application.Quit acSaveYes
End Sub
Okay... a "helper" function:
API: Get Login name
Author(s)
Dev Ashish
http://www.mvps.org/access/api/api0008.htm
(Q) How do I retrieve the UserName with which the user is logged into
the network?
(A) Paste the following code in a new module and call the function
fOSUserName.
'******************** Code Start **************************
' This code was originally written by Dev Ashish. ' It is not to be
altered or distributed,' except as part of an application. ' You are
free to use it in any application, ' provided the copyright notice is
left unchanged.'' Code Courtesy of ' Dev Ashish'
Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Function fOSUserName() As String
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUserName As String
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)
If ( lngX > 0 ) Then
fOSUserName = Left$(strUserName, lngLen - 1)
Else
fOSUserName = vbNullString
End If
End Function
'******************** Code End **************************
Okay, here's the code:
Public Sub LogKickouts()
Dim strSQL As String
strSQL = "INSERT INTO KickedOutUsers ( UserName, Reason ) VALUES
('" & fOSUserName & "', 'Idle Too long');"
DBEngine(0)(0).Execute strSQL
End Sub