Results 1 to 2 of 2
  1. #1
    jlgray0127 is offline Competent Performer
    Windows 7 64bit Access 2003
    Join Date
    Oct 2011
    Location
    Central Illinois
    Posts
    185

    Windows Log In "Username" in an append query

    I have a database I'm building, which will pull info from an ODBC Connection.
    I'm taking this information, and from there, using the database as a scheduling tool for our production lines. There are forms, append querys, (that run from a macro updating information in the table, ect... I'm trying to capture the user name for every action the user is doing.
    I've found the below code, but am not sure what to do with it. I believe you create a module with it, but am unsure how, or if I even can, call the module in query to append the user name to each record from the append query. Please help! LOL

    Function UserNameWindows() As String
    UserName = Environ("USERNAME")
    End Function



    or

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

    Dim strLen As LongDim strtmp As String * 256Dim strUserName As StringstrLen = 255GetUserName strtmp, strLenstrUserName = Trim$(TrimNull(strtmp))

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    You don't call the module, you call the function. You'd have the function name instead of a field name in the query. By the way, the first would fail because you haven't set the function name.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 1
    Last Post: 02-17-2013, 04:46 PM
  2. Environ("username") ---> #Name? Error
    By KiEESH in forum Forms
    Replies: 2
    Last Post: 02-15-2013, 07:23 AM
  3. Replies: 5
    Last Post: 02-05-2013, 10:57 PM
  4. Automating "Append" Query with Parameters
    By Monterey_Manzer in forum Queries
    Replies: 1
    Last Post: 10-04-2012, 12:00 PM
  5. Replies: 0
    Last Post: 12-06-2011, 11:01 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