Results 1 to 3 of 3
  1. #1
    undee_69 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    May 2014
    Posts
    9

    Printing of login information


    Dear Sirs/Maams,

    Good day to all of you here.

    I would like to ask your assistance.

    I would like to print a report but the report should include the name of the person logged into the ms access.

    Is there a way that I can do this?

    thank you very much.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    Add this code to a module, then in the query call: getUserID()


    Code:
    Option Compare Database
    Public Const C_STARTCOUNT As Integer = 1001
    Public Const C_MIN_LIST_HEIGHT As Integer = 3675
    Public Const C_MAX_LIST_HEIGHT As Integer = 4210
    Public Const MAX_PATH = 260
    Public Const CSIDL_FLAG_MASK = &HFF00                    'mask for all possible flag values
    Public Const SHGFP_TYPE_CURRENT = &H0                    'current value for user, verify it exists
    Public Const SHGFP_TYPE_DEFAULT = &H1
    Public Const S_OK = 0
    Public Const S_FALSE = 1
    Public Const E_INVALIDARG = &H80070057                   ' Invalid CSIDL Value
    'Use the GetUserName API function.
    Public Declare Function SHGetFolderPath Lib "shfolder" Alias "SHGetFolderPathA" (ByVal hwndOwner As Long, ByVal nFolder As Long, ByVal hToken As Long, ByVal dwFlags As Long, ByVal pszPath As String) As Long
    Public Declare Function WNetGetUserA Lib "mpr.dll" (ByVal lpName As String, ByVal lpUserName As String, lpnLength As Long) As Long
      
    ' Return the user's name.
    Public Function getUserID() As String
    Dim sBuffer As String * 255
    Dim sName As String
    sBuffer = Space(255)
    Call WNetGetUserA(vbNullString, sBuffer, 255&)
    sName = Left$(sBuffer, InStr(sBuffer, vbNullChar) - 1)
    If Len(sName) Then
        getUserID = LCase$(sName)
    Else
        getUserID = "<Unknown>"
    End If
    End Function

  3. #3
    undee_69 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    May 2014
    Posts
    9
    I added it to the module. which query will i be adding it to? attached is a sample that I am doing.DB_Print Login.zip

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

Similar Threads

  1. Replies: 3
    Last Post: 05-02-2014, 09:27 AM
  2. Replies: 1
    Last Post: 02-17-2013, 04:46 PM
  3. Windows User Login Information
    By MintChipMadness in forum Programming
    Replies: 6
    Last Post: 08-07-2012, 05:47 PM
  4. Login form with nt login
    By hitesh_asrani_j in forum Forms
    Replies: 6
    Last Post: 09-22-2011, 11:43 AM
  5. Replies: 2
    Last Post: 08-20-2010, 04: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