Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Login ID idea/problem???

Status
Not open for further replies.

WB786

MIS
Mar 14, 2002
610
I am using the following code to capture the login id of user:

Option Compare Database
Option Explicit

Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
'inl as 1

Function GetUser() As String

Dim lpUserID As String
Dim nBuffer As Long
Dim Ret As Long
'lpUserID = String(25, 0)
lpUserID = " "
nBuffer = 25
Ret = GetUserName(lpUserID, nBuffer)

If Ret Then
GetUser$ = lpUserID$
End If

End Function

I have an employee database that the IT departments updates the info with person's login ID and stuff. I am designing a form where the records on that form should be for the person that has logged into the computer:

Currently my query does this after the user selects their name from a drop down:

[Forms]![Switchboard]![EmployeeLogin]

But I want the form to capture the loginID and then see who is logging in and pull up the employee's name for that loginID from the database and then run this query. Any ideas?? Please let me know if more info is needed. Thanks in advance.
 
Maybe I've read you message wrong but can't you just use the CurrentUser() function to return the user name? You can simply just run a query with the CurrentUser() function as a criteria?
 
CurrentUser() works in a query but here is my problem. The work-assigned-to-an-employee table will only have the employee's name and not the login id info. There is a linked table to the employee database (sql) that has all the info, employee name, login id, email, etc. So based on the login id it should pull the employee name from the sql database and then query the records based on the employee's name. Let me know if you need more info. Thanks both and I will be reading the other post to find an answer as well.

:)WB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top