12 replies
by bob sellman
Here's a part of the answer to your question.
Create a module (or add to one) the following:
PUBLIC txtUserID as text
This will create the text variable txtUserID that will be available everywhere in your application.
I don't know how to get the login ID from the operating system, so let's assume you create a login form that starts when the user starts the application and matches the ID and password against a table within your application. If there is a match, open your application'smain form after the following (assuming UserIDControl refers to the control on your login form containing the user ID):
txtUserID = me.UserIDControl
On your input form set the default value of a hidden text control (we'll call it currentUserID) on the form equal to the public valiable txtUserID. (The control currentUserID will have its data source set to UID.) The user id will then be saved with the rest of the new record.
Contact me if you are using this solution and need more specific code, including the login to Access. (Note that I am not using the Access security system.)
I'm also very interested in learning if User IDs can be obtained from Netware 3/4/5 and Windows NT/2000 operating systems.
by donq
by tclere
This may be tough to read because they changed the format of the postings. They removed all line feeds and tabs which makes posting readable code almost impossible.
To get the user ID in windows using VB:
Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Dim ret As Long
Dim lpBuff As String * 25
Dim sUserInitials as String
ret = GetUserName(lpBuff, 25)
sUserInitials = Left(lpBuff, InStr(lpBuff, Chr(0)) - 1)
sUserInitials = UCase(sUserInitials)
Hope this helps. I have the 'Notification' marked in case you need any more help with this solution.
by joetech3
by donq
by sheryl v
You Need the declaration & the function. Set the default value to "=GetUserName()
CODE:
Declare Function DeclareGetLogin Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Function GetUserName() As String
On Error GoTo Err_GUN
Dim lngLen As Long
Dim strBuf As String
Const MaxUserName As Integer = 255
strBuf = Space(MaxUserName)
lngLen = MaxUserName
If CBool(DeclareGetLogin(strBuf, lngLen)) Then
GetUserName = Left$(strBuf, lngLen - 1)
Else
GetUserName = ""
End If
Exit_GUN:
Exit Function
Err_GUN:
msgbox Err.Description
Resume Exit_GUN
End Function
by donq
by mikeb
In an application of this type, you can get into some serioius problems if your network security settings allow this.
Here is a work-around that I have used:
create another table that includes UID, password and any other fields you need then have the user login separately against this table to gain access to the database, then any of the fields in this table are available to use any way you want. I know this is inconvenient to require users to log in twice, but there is always a tradeoff between convenience and security.
by donq
by donq
This discussion is closed to new replies.
Trending Web Development posts
Sort by Trending