Results 1 to 4 of 4
  1. #1
    pimpzter is offline Novice
    Windows XP Access 2003
    Join Date
    Apr 2012
    Posts
    22

    show usename when textbox is dblclick


    I am looking for a way to display a windows login name when the user double clicks on a text box. This is for a digital signature on a form that i dont want people having access to just type in some elses name. I have searched these forums as well as google and am stumped. any help or direction is greatly appreciated.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    They dont have to click it... just make it populate when the form opens (or your way)

    txtBox = Environ("Username")

  3. #3
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Be aware that by using a DOS window, it is possible to spoof the user name environmental variable.

    There is code to "Get Login name" using an API at http://access.mvps.org/access/api/api0008.htm

  4. #4
    tonez90 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jul 2014
    Location
    Australia
    Posts
    18
    You can get username a number of ways. Do you have a network, use active directory or just simple invidual machines networked.
    Here is a function that works well (it also gives the machine name as well)
    . Hope it helps
    '================================================= =====================

    Private Declare Function api_GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
    Private Declare Function api_GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long

    Public Function atCNames(UOrC As Integer) As String
    '************************************************* *
    'Purpose: Returns the User LogOn Name or ComputerName
    'Accepts: UorC; 1=User, anything else = computer
    'Returns: The Windows Networking name of the user or computer
    '************************************************* *
    On Error Resume Next
    Dim NBuffer As String, sDump As String
    Dim Buffsize As Long, Wok As Long, lR As Long
    Buffsize = 256
    ' NBuffer = Space(256)
    NBuffer = Space$(Buffsize)
    If UOrC = 1 Then
    Wok = api_GetUserName(NBuffer, Buffsize)
    atCNames = Left$(NBuffer, InStr(NBuffer, Chr(0)) - 1)
    Else
    Wok = api_GetComputerName(NBuffer, Buffsize)
    atCNames = Left$(NBuffer, InStr(NBuffer, Chr(0)) - 1)
    End If
    sDump = String$(255, " ") 'Create a buffer
    lR = api_GetUserName(sDump, 255) 'Fill buffer with ID
    ' GetUserName1 = Left$(sDump, InStr(1, sDump, vbNullChar) - 1) 'Return just the id and I use this for something else
    ' MsgBox (sDump & " " & Wok & lR & " --- " & GetUserName1)
    End Function

    '================================================= ================================

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 07-31-2014, 10:44 AM
  2. Replies: 4
    Last Post: 04-03-2014, 08:03 AM
  3. Replies: 4
    Last Post: 07-07-2012, 07:14 PM
  4. Replies: 2
    Last Post: 09-26-2009, 07:19 AM
  5. Replies: 0
    Last Post: 05-16-2008, 07:50 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums