May 13th, 2016, 01:57 AM
Join Date: May 2016
Time spent in forums: 30 m 49 sec
Reputation Power: 0
How To Update Logout Time in LoginLog Table when user is sudden removed their LAPTOP
I need your help on Access VBA 2007, How To system will automatically update Logout Time in LoginLog Table when user is sudden disconnected on Network Connection OR sudden removed LAN cable from their Laptop.
Below is my Login_Form VBA Code, here i am using Sub Form_Close() event and it is working fine when user is properly logout on this application.
If user sudden remove their network cable from laptop then this LoginLog_ID is always showing on Who’s Online Query because i have created Who’s Online Query based on LoginLog Table where LogOut Time is Null. Next time when he will again Login this Application, on Who’s Online Query will showing duplicate records on this user.
I have automated if any new task was came on TaskDetail Table then automatically allocate user who’s online against New Tasks, that scenario when user will not Logout this Application properly then this user will showing always as Online and system will always assign new tasks to this user continually.
In my Application i am not using Login sessions if required please suggest and also suggest how/where to use session in my application.
Public GlobalEmpCode As Variant
Public GlobalEmpName As Variant
Public GlobalLngLoginId As Long
Private Sub cmdLogin_Click()
Dim con As Object
Dim Rs As Object
Set con = Application.CurrentProject.Connection
Set Rs = CreateObject("ADODB.Recordset")
Rs.Open "select * from SRT_tblEmployees where lngEmpID='" & txtLoginID.Value & "' and strEmpPassword='" & txtPassword.Value & "'", con, 1, 3
If Rs.RecordCount > 0 Then
GlobalEmpCode = Rs.Fields("lngEmpID").Value
GlobalEmpName = Rs.Fields("strEmpName").Value
Dim rs2 As Object
Set rs2 = CurrentDb.OpenRecordset("SRT_tblLoginLog")
rs2.Fields("Emp_ID") = GlobalEmpCode
rs2.Fields("Emp_Name") = GlobalEmpName
rs2.Fields("Login_Date") = Now()
GlobalLngLoginId = rs2(0)
Set rs2 = Nothing
If Rs.State = 1 Then Rs.Close
Set Rs = Nothing
Private Sub Form_Close()
Dim RsL As DAO.Recordset
Set RsL = CurrentDb.OpenRecordset("SELECT * FROM SRT_tblLoginLog WHERE ID =" & GlobalLngLoginId)
If Not RsL.EOF And Not RsL.BOF Then
RsL.Fields("Logout_Date").Value = Now()
Set RsL = Nothing