473,666 Members | 2,114 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help Recording LogOn/Off

365 Contributor
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 1857
ChipR
1,287 Recognized Expert Top Contributor
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 Contributor
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
5549
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" + "\\root\\CIMV2:Win32_Process");
10
1304
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 could and came up with some errors I could not understand. Any Help would be appreciated. Using: MS Visual Studio .Net 2003
1
1818
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
1233
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 should, but im not convinced extract all the remaining records that do not have a matched recording, but fulfil the rest of the criteria. If not please help...
1
2396
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. thanks for giving me a little clue, and Great U for sending me a copy of code of C#. or I will be Fired in a week.
12
1821
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 entering data into the database. I would like to know how I record the username of each unique data entry operator against any entries they input into the database?
8
3863
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 code originate from a VB 6 application, and I'm trying to use vb 2005. I was having a lot of issues until I saw your post that cleaned up a lot of the structures and DLL calls in this: ...
2
1286
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 For Recording I used ======================================================= Dim settings As String Dim Alignment As Integer
4
1766
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 video signal, here i am using my Nvidia Geforce 6600 graphics card as video input device, the video source is a small camera which is outputting the video through composite video cable and that cable is attached to the input connector of my vga card. ...
0
8356
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8550
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8639
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7385
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6192
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5663
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4198
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2769
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.