MS Access

 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me



Go Back   Tutorialized ForumsDatabasesMS Access

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Tutorialized Forums Sponsor:
  #1  
Old May 13th, 2016, 01:57 AM
arjun5381 arjun5381 is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: May 2016
Posts: 3 arjun5381 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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

Dear All,
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.AddNew
rs2.Fields("Emp_ID") = GlobalEmpCode
rs2.Fields("Emp_Name") = GlobalEmpName
rs2.Fields("Login_Date") = Now()
rs2.Update
rs2.MoveFirst
DoEvents
rs2.MoveLast
GlobalLngLoginId = rs2(0)
rs2.Close
Set rs2 = Nothing

Else
If Rs.State = 1 Then Rs.Close
Set Rs = Nothing
Exit Sub
End If

End Sub



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.Edit
RsL.Fields("Logout_Date").Value = Now()
RsL.Update
RsL.Close
End If
Set RsL = Nothing
End Sub

Reply With Quote
Reply

Viewing: Tutorialized ForumsDatabasesMS Access > How To Update Logout Time in LoginLog Table when user is sudden removed their LAPTOP


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.

© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap