p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

access thread: Using system variables (Login name)


Message #1 by Paul Bucknell <paul@d...> on Sat, 08 Jun 2002 17:19:58 +0100
I work in a department and am trying to do some development with Access 97. 
What I really need is to put into a variable the Windows Login name. i.e. 
when I start my computer and get to the login screen (we have a LAN) then I 
type in (if I need to) BucknellP, then my password.

I need to have access to the BucknellP from within Access. Is this possible?

kindest regards
Paul Bucknell

Message #2 by "Carnley, Dave" <dcarnley@a...> on Mon, 10 Jun 2002 08:50:22 -0500
my apps ruin on various versions of NT, and this is what I use to get the
users' login names

Declare Function WNetGetUser Lib "mpr.dll" _
   Alias "WNetGetUserA" (ByVal lpName As String, _
   ByVal lpUserName As String, lpnLength As Long) As Long
 
Global Const gcNO_ERROR = 0        'The Function call was successful
Global Const gcUserNotFound = 94

Public Function gUtil_GetUsersID() As String
    ' Buffer size for the return string.
    Const lpnLength As Integer = 255
    
    ' Get return buffer space.
    Dim status As Integer
    
    ' For getting user information.
    Dim lpName, lpUserName As String
    
    ' Assign the buffer size constant to lpUserName.
    lpUserName = Space$(lpnLength + 1)
    
    ' Get the log-on name of the person using product.
    status = WNetGetUser(lpName, lpUserName, lpnLength)
    
    ' See whether error occurred.
    If status = gcNO_ERROR Then
       ' This line removes the null character. Strings in C are null-
       ' terminated. Strings in Visual Basic are not null-terminated.
       ' The null character must be removed from the C strings to be used
       ' cleanly in Visual Basic.
       lpUserName = Left$(lpUserName, InStr(lpUserName, Chr(0)) - 1)
    Else
       ' An error occurred.
       lpUserName = "UNKNOWN"
    End If
    
    gUtil_GetUsersID = lpUserName
End Function


-----Original Message-----
From: Paul Bucknell [mailto:paul@d...]
Sent: Saturday, June 08, 2002 11:20 AM
To: Access
Subject: [access] Using system variables (Login name)


I work in a department and am trying to do some development with Access 97. 
What I really need is to put into a variable the Windows Login name. i.e. 
when I start my computer and get to the login screen (we have a LAN) then I 
type in (if I need to) BucknellP, then my password.

I need to have access to the BucknellP from within Access. Is this possible?

kindest regards
Paul Bucknell



  Return to Index