473,387 Members | 1,504 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,387 software developers and data experts.

Identifying Front End Filename Accessing the Back End

108 64KB
Hi All,
I'm trying to fine tune my audit trail to be a little more accurate as to who is using the database. I'm running Access 2013 on Windows 10 with split front- and back-ends and about 8 total users. I am currently using the Environ("COMPUTERNAME") function to populate my [ChangedBy] field in my data macro audit trail. Sometimes people may be logged into someone else's computer at my office so I want to be able identify which front-end file is making the changes from the back-end. The problem is that my data macros are stored in the back-end on one machine (we're on a WorkGroup network), so if someone is at a computer that isn't their own but they are in their own front-end file, the function will return the computer name and not the actual user making the changes. I need some kind of function that returns the name of the file that is accessing the back-end.
Any help is much appreciated...
Thanks in advance.
Nov 25 '15 #1
2 1253
jforbes
1,107 Expert 1GB
You could use:
Expand|Select|Wrap|Line Numbers
  1. Application.CurrentProject.FullName
  2. or
  3. Application.CurrentProject.Path
to return the path/filename of the executing database.

Another useful piece of information is the Currently logged in Windows Username. This code is floating around in various forms on the Internet:
Expand|Select|Wrap|Line Numbers
  1. ' Place this in Module
  2. Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
  3.  
  4. Public Function GetWindowsUser() As String
  5.     On Error GoTo ErrorOut
  6.  
  7.     Dim lngResponse As Long
  8.     Dim strUserName As String * 32
  9.  
  10.     lngResponse = GetUserName(strUserName, 32)
  11.     GetWindowsUser = Left(strUserName, InStr(strUserName, Chr$(0)) - 1)
  12.  
  13. ExitOut:
  14.     Exit Function
  15. ErrorOut:
  16.     MsgBox Err.Description
  17.     Resume ExitOut
  18. End Function
  19.  
Nov 26 '15 #2
zmbd
5,501 Expert Mod 4TB
I would suggest using J's second block of code to determine which user is logged in to the PC and it is essentially the same code I use for such things.

File names and the system environment variables can be altered.

This is the code I borrowed from Dev Ashish ages ago.
Following his lead, I needed the name assigned to the PC so I wrote another function based on Ashish's example. Notice that I use the "PtrSafe" in the declaraions to account for 64Bit installs... if for some reason this chokes try deleting it.

This has been tested several times and is in a production database I use:

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.  
  4. '******************** Code Start **************************
  5. ' This code was originally written by Dev Ashish.
  6. ' It is not to be altered or distributed,
  7. ' except as part of an application.
  8. ' You are free to use it in any application,
  9. ' provided the copyright notice is left unchanged.
  10. '
  11. ' Code Courtesy of
  12. ' Dev Ashish
  13. '
  14. '
  15. 'ZMBD: Added the PtrSafe - have some 64bit installs that need this
  16. Private Declare PtrSafe Function apiGetUserName Lib "advapi32.dll" Alias _
  17.     "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
  18.  
  19. '
  20. 'ZMBD: I want the PC name too - :)
  21. 'ZMBD: Added the PtrSafe - have some 64bit installs that need this
  22. Private Declare PtrSafe Function apiGetComputerName Lib "kernel32" Alias _
  23.     "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
  24.  
  25. Function fOSUserName() As String
  26. ' Returns the network login name
  27. Dim lngLen As Long, lngX As Long
  28. Dim strUserName As String
  29.     strUserName = String$(254, 0)
  30.     lngLen = 255
  31.     lngX = apiGetUserName(strUserName, lngLen)
  32.     If (lngX > 0) Then
  33.         fOSUserName = Left$(strUserName, lngLen - 1)
  34.     Else
  35.         fOSUserName = vbNullString
  36.     End If
  37. End Function
  38. '
  39. '
  40. 'ZMBD: Based on the above and from the Win32API_PtrSafe.txt
  41. Function fOSPCName() As String
  42. ' Returns the network login name
  43. Dim lngLen As Long, lngX As Long
  44. Dim strPCName As String
  45.     strPCName = String$(254, 0)
  46.     lngLen = 255
  47.     lngX = apiGetComputerName(strPCName, lngLen)
  48.     If (lngX > 0) Then
  49.         fOSPCName = Left$(strPCName, lngLen - 1)
  50.     Else
  51.         fOSPCName = vbNullString
  52.     End If
  53. End Function
  54.  
  55. '******************** Code End ************************
Nov 26 '15 #3

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

Similar topics

3
by: Matt | last post by:
I always heard people saying IIS ASP front end, and MS-SQL back end. ASP is for server side programming and dynamic content generation, how could it is called front end? Because I thought it is...
8
by: Rob | last post by:
Dear all I'm well into designing my first ever Access database which is currently about 13 megs (.mdb file) containing data on progress and attainment of approx 500 students. What I want to...
6
by: John Welch | last post by:
I have a potential client who wants an application with about 20,000 records and 5-8 users. I told him that Access would work fine, but he wants to go with an mdb front end linked to SQL Server...
24
by: Bob Alston | last post by:
Most of my Access database implementations have been fairly small in terms of data volume and number of concurrent users. So far I haven't had performance issues to worry about. <knock on wood> ...
4
by: Brad P | last post by:
I have a 2K database with a front end linked to a back end. I need to lock down or secure both ends so a user can not access the raw data in tables etc. I also need usernames and passwords for 50+...
0
by: Ron Adam | last post by:
Is there a function to find a filename from a dotted module (or package) name without importing it? The imp function find_module() doesn't work with dotted file names. And it looks like it may...
2
lwwhite
by: lwwhite | last post by:
Access 2003. I am maintaining 5 almost identical databases (long story). Each of them is split into a back end and front end. While individual maintenance of the back ends is inevitable, I would...
0
by: p-rat | last post by:
I have a database that Sql Server back end Access front end. I have linked tables. At first when logging out of my network and back in the tables wouldn't stay linked and I would have to re-link...
18
by: afromanam | last post by:
Whew.. OK, running access 2003 in win xpsp2 and access 2007 in win vista. This is the question... We have a db, split in front end (FE.mdb) and backend (BE.mdb) FE has tons of linked...
2
by: hrprabhu | last post by:
Hi, How do I automatically connecting front end and back end of a database? I have to go to tools-> Linked Table manager -> and link tables when ever I move the back end and the front end for what...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...

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.