473,405 Members | 2,294 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Help Recording LogOn/Off

365 100+
Expand|Select|Wrap|Line Numbers
  1. Function LogonLog(OnOff As String)
  2. Dim rst As DAO.Recordset
  3. If OnOff = "On" Then
  4.     Set rst = CurrentDb.OpenRecordset("tblLogonLog", dbOpenDynaset, dbAppendOnly)
  5.         rst.AddNew
  6.           rst!StaffID = LogStaffID
  7.           rst!Logon = Now()
  8.         rst.Update
  9. ElseIf OnOff = "Off" Then
  10.     Set rst = CurrentDb.OpenRecordset("SELECT Max(tblLogonLog.LID) AS LID FROM tblLogonLog HAVING (((tblLogonLog.StaffID)=1) AND ((tblLogonLog.LogOff) Is Null));")
  11.     DoCmd.SetWarnings False
  12.     DoCmd.RunSQL ("UPDATE tblLogonLog SET tblLogonLog.LogOff = Now() WHERE (((tblLogonLog.LID)=" & rst!LID & "));")
  13.     DoCmd.SetWarnings True
  14. End If
  15.     rst.Close
  16. End Function
Hello, i have some code that records logon/off time and date at logon/off and i think the log off is a bit sloppy, wondered if there was a better/more efficient way? of course i need to know the LineID (LID) to match on and off which is where my problem arises. one thing i wondered is can you read the value (autonumber) whilst appending by DAO (in the logon) so that i can store it as global variable?

thanks for any help
Jul 21 '09 #1
2 1838
ChipR
1,287 Expert 1GB
You don't need to open a recordset for either of these things. For example, I keep the logon time in a global variable. Here's the code I've been using for a while.
Expand|Select|Wrap|Line Numbers
  1. Private Sub StartUp()
  2. On Error GoTo ErrorHandler
  3.     ...
  4.     startTime = Now
  5.     strSQL = "INSERT INTO UsageLog (StartTime, UserName, Workstation) VALUES (#" _
  6.      & startTime & "#, """ & userName & """, """ & Workstation & """);"
  7.     DoCmd.SetWarnings False
  8.     DoCmd.RunSQL strSQL, 0
  9.     DoCmd.SetWarnings True
  10.     ...
  11.     'Show Main Menu is in here somewhere
  12. End Sub
  13.  
  14. 'Form Unload for the Main Menu
  15. Private Sub Form_Unload(Cancel As Integer)
  16. On Error GoTo ErrorHandler
  17.     Dim strSQL As String
  18.     'record user log off
  19.     strSQL = "UPDATE UsageLog SET EndTime = #" & Now & "# WHERE StartTime = #" & startTime & "#;"
  20.     DoCmd.SetWarnings False
  21.     DoCmd.RunSQL strSQL, 0
  22.     DoCmd.SetWarnings True
  23.     ...
  24. End Sub
Jul 21 '09 #2
Dan2kx
365 100+
spose that would work, never thought about saving start time lol i was focused on the autonumber.

Thanks
Jul 21 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: ricolee99 | last post by:
Hi everyone, I'm trying to invoke my .exe application from a remote server. Here is the code: ManagementClass processClass = new ManagementClass ("\\\\" +"RemoteServerName" +...
10
by: gonzal51 | last post by:
Hi, I'm a student learning C++ and my professor isn't much help, her view is if you dont get it I ain't helping you.... We are supposed to do a basic program as a logon system. I got as far as I...
1
by: Sakharam Phapale | last post by:
Hi All, I am developing an application like sound recorder. While recording if there is a silence for more than given time (say 5 seconds), Recording should be paused.
4
by: David | last post by:
Hi, I was hoping someone could confirm the following about the following number 2 SQL query: 1. This extracts the data required given that there is a recording to match the records 2. This...
1
by: zhangzhi | last post by:
HI£º i have a big problem about audio recording. my boss wanna a application of audio monitor, and he wanna it will detect voice and start recording automatically, avoiding recording silences....
12
by: chris.thomson | last post by:
Hi, Thanks in advance for any assistance regarding my question. I have setup a database with a WIF containing the usernames and p/words of several unique data entry operators who will be...
8
by: jer | last post by:
I've noticed you've helped a lot of people that were trying to do sound recording through VB.net. I'm searched all over the internet, and I'm still having problems write sound to a wav file. My...
2
by: taaz | last post by:
I'm developing the Delay Audiometry feedback. My Step are... Recording -> Playing... these are on different events. I've used the mcisendstring()for manipulation of audio & made the functions ...
4
by: tahirahmed | last post by:
Hello, Before i start programming my application in C# I want ask a few things about directX capture class. My application scenario I want to design an application which is able to detect...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.