Results 1 to 2 of 2
  1. #1
    altemir is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2012
    Posts
    31

    How to Get Current SQL User?


    I have an Access 2010 front-end linked to a SQL Server 2008 back-end. The linked tables in the front-end use SQL login authentication (as opposed to Windows NT authentication). My question is what can I do with VBA to obtain the current SQL user that was authenticated for the current session?

    I'm looking for something like Environ("UserName"), which gets me the current Windows user.

  2. #2
    altemir is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2012
    Posts
    31
    No sooner did I post this question, than I found the answer. All I did was create a pass-through query that contained "EXEC sp_who2". This query returns a one-row recordset that contains the current user login. You can then access this query with VBA using DAO or ADODB.

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

Similar Threads

  1. Tasks and the current user!
    By WhiskyLima in forum SharePoint
    Replies: 0
    Last Post: 10-23-2013, 04:18 AM
  2. permission & change current user
    By mye887 in forum Access
    Replies: 1
    Last Post: 06-05-2013, 12:25 AM
  3. Replies: 1
    Last Post: 07-11-2012, 08:52 AM
  4. Selecting based on current user
    By shabbaranks in forum Programming
    Replies: 3
    Last Post: 01-27-2012, 07:07 AM
  5. Access 2010 : Current logged in user
    By raghav_pegausis in forum Access
    Replies: 7
    Last Post: 10-24-2011, 02:52 PM

Tags for this Thread

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