![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Lets say that my WinXP computer has two users: Michael and Kathryn. One or the other logs into the computer and opens up an Access database (I happen to be using 2002). There is no security on the database -- just click on the shortcut and you're in. I want to be able to determine who opened that database by knowing who logged into the computer. Is there a way to get the windows user name? I have another question, and this one may be a bit off-topic, but I'll run it up the flagpole. I want to leave the above-named database open all the time, such that whenever anybody logs in at the windows login screen, the database will be up and running. In the actual application there may be as many as twenty people accessing the same application, and I don't want twenty instances of the program running -- one for each user. Can I have that database display on the screen of all users? (Specifically, I would like to use Windows Fast User Switching to change users.) In most situations, I could resolve these issues using Access' security features. This is a unique application, though, and the users won't be able to log into the database themselves. Thanks! Mike |
#3
| |||
| |||
|
|
Mike, I had to build a database recently that needed to know who was logged in. Create a module and place this in the declarations section: ************************************** Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long ************************************** Then create a function that looks something like this: ************************************** Function GetUser() As String ' Procedure: GetUser() ' Modified: 26 Aug 2004 RAM ' Purpose: Necessary Function for WINAPI Function, GetUserName ' Input: N/A ' Output: GetUser$ Dim lpUserID As String Dim nBuffer As Long Dim Ret As Long lpUserID = String(25, 0) nBuffer = 25 Ret = GetUserName(lpUserID, nBuffer) If Ret Then GetUser$ = lpUserID$ End If End Function ************************************** When you run the GetUser() function it returns the UserID of the person currently logged into the computer. I hope this helps. Rob "Mike Turco" <miketurco (AT) yahoo-nospam4me (DOT) com> wrote Lets say that my WinXP computer has two users: Michael and Kathryn. One or the other logs into the computer and opens up an Access database (I happen to be using 2002). There is no security on the database -- just click on the shortcut and you're in. I want to be able to determine who opened that database by knowing who logged into the computer. Is there a way to get the windows user name? I have another question, and this one may be a bit off-topic, but I'll run it up the flagpole. I want to leave the above-named database open all the time, such that whenever anybody logs in at the windows login screen, the database will be up and running. In the actual application there may be as many as twenty people accessing the same application, and I don't want twenty instances of the program running -- one for each user. Can I have that database display on the screen of all users? (Specifically, I would like to use Windows Fast User Switching to change users.) In most situations, I could resolve these issues using Access' security features. This is a unique application, though, and the users won't be able to log into the database themselves. Thanks! Mike |
![]() |
| Thread Tools | |
| Display Modes | |
| |