Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 746
  • Last Modified:

Getting NT User Name within VBA Code in Access 97

How do I get a username using VBA inside an Access 97 database?  I need to look at the NT user name inside the code to sort out access rights.  I need SUGGESTIONS!!
0
JOwings
Asked:
JOwings
1 Solution
 
DRRYAN3Commented:
In a module, put this line of code

Public Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpbuffer As String, nSize As Long) As Long


As a test, you can put this code on a button

Private Sub Command1_Click()
    Dim sBuffer As String
    Dim lSize As Long
    sBuffer = Space$(255)
    lSize = Len(sBuffer)
    Call GetUserName(sBuffer, lSize)
    If lSize > 0 Then
        Command1.Caption = Left$(sBuffer, lSize)
    End If
End Sub

Run the form, click on the button and your login name should appear on the button.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now