473,408 Members | 2,402 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,408 software developers and data experts.

Can I trace the last person who used the database?

Hi all,

Great day(:

I have a database stored in the shared drive and currently the records are being changed mysteriously. Is there a function in MS Access that allows you to check who was the last person who used the database or who was the one who changed a record?

Many thanks for all the help received(:

Cheers,
Nicole
Feb 11 '10 #1

✓ answered by ADezii

Assuming you have User-Level Security defined, you can Log each User's opening and closing of the Database by writing to a Hidden Table, then easily retriving that information. You can use something similar to:
Expand|Select|Wrap|Line Numbers
  1. Dim strSQL As String
  2.  
  3. strSQL = "INSERT INTO tblLastUser ([UserName], [UsageTime]) VALUES (CurrentUser(), Now())"
  4.  
  5. CurrentDb.Execute strSQL, dbFailOnError
To retrieve the Last User's Name and Time Logged on:
Expand|Select|Wrap|Line Numbers
  1. MsgBox "Last User: " & DLast("[UserName]", "tblLastUser") & vbNewLine & _
  2.        "Last Access: " & DLast("[UsageTime]", "tblLastUser")
Example:
Expand|Select|Wrap|Line Numbers
  1. Last User: Admin
  2. Last Access: 2/11/2010 9:20:29 AM

4 2988
ADezii
8,834 Expert 8TB
Assuming you have User-Level Security defined, you can Log each User's opening and closing of the Database by writing to a Hidden Table, then easily retriving that information. You can use something similar to:
Expand|Select|Wrap|Line Numbers
  1. Dim strSQL As String
  2.  
  3. strSQL = "INSERT INTO tblLastUser ([UserName], [UsageTime]) VALUES (CurrentUser(), Now())"
  4.  
  5. CurrentDb.Execute strSQL, dbFailOnError
To retrieve the Last User's Name and Time Logged on:
Expand|Select|Wrap|Line Numbers
  1. MsgBox "Last User: " & DLast("[UserName]", "tblLastUser") & vbNewLine & _
  2.        "Last Access: " & DLast("[UsageTime]", "tblLastUser")
Example:
Expand|Select|Wrap|Line Numbers
  1. Last User: Admin
  2. Last Access: 2/11/2010 9:20:29 AM
Feb 11 '10 #2
Hi ADezii,

By saying" Assuming you have User-Level Security defined, you can Log each User's opening and closing of the Database by writing to a Hidden Table"

Could you elaborate more about the User-Level Security as i have no idea what that is about. And also with regards to the Hidden Table,does this mean i have to create a new table?

Sorry for the many question, this is all very new to me. Where will i have to put the codes? Do i have to put it in each table and is there a button i can cliick to retrieve the info for the last person using the DB.

Thanks in advance for all your help ADezii, appreciate it heaps(:
Cheers,
Nicole
Feb 12 '10 #3
NeoPa
32,556 Expert Mod 16PB
User-Level is a bit of a dead duck now. I believe they don't even support it going forward from A2007.

However, this does open my eyes a little (Thanks ADezii). I was assuming, quite sleepily, that you were asking for a general concept of how to determine such usage (IE. for any unmodified database). For a particular database you could always log the user accesses. In place of the Access level user though (almost all Access users simply use Administrator for all purposes) you could use the network user, or simple account name if the user is not networked.

Function to Return UserName (NT Login) of Current User and Retrieve User ID will help to get those details. ADezii's code and explanation gives the basic idea of how to go about this.
Feb 12 '10 #4
NeoPa
32,556 Expert Mod 16PB
@nicolenwn
Yes it would. You could hide it from the users as ADezii has suggested if that helps, but you'd need a table to log the access times into.

It could be done by logging to an outside file, but that would be appreciably more complicated and somewhat less logical.
Feb 12 '10 #5

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

Similar topics

4
by: Drifter | last post by:
Using HTTP_REFERER I cannot capture the URL when the link is made via a button: <input type="button" name="Continue" value="Continue Shopping"...
3
by: Robert | last post by:
Greetings, I have been attempting to develop a useful and functional template for database tracing/profiling that will enable me to collect metrics for performance tuning. The database is used...
0
by: FAQPoster | last post by:
An HTML version of this document is available at: http://www.mvps.org/access/netiquette.htm Feeling left out? Alone? Wondering why everyone's ignoring you? Or why you're being flamed for what...
6
by: latosca68 | last post by:
I need to demostrate, in a forensic job, that I can change (insert, update, delete) records in a table of an access database without trace. How can I do this ? I plan to make the queries or export...
2
by: dauwe.peter | last post by:
A table : Nameperson, Book nr, Bookdatein, Bookdateout, CD nr, cddatein, cddateout, dvd nr, dvddatein, dvddateout. I would like a query where a see the personsname en de last book with the...
8
by: twomcfly | last post by:
Hi I have a SQL Server 2005 database with a list of results for a variety of people over time. i would like to be able to look at any row and from that row know the last 3 results for that person...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...
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
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.