Results 1 to 8 of 8
  1. #1
    pkstormy's Avatar
    pkstormy is offline Access/SQL Server Expert
    Windows XP Access 2003
    Join Date
    Mar 2010
    Location
    Madison
    Posts
    682

    GetUser method

    The following is a simple way to securely grab the user's windows loginID.



    Note: required is the class modules: SystemInfo and the module: UserName (Getuser) which has the function to return the user's loginID. Just import these into your mdb/accdb project.

    Also see class module: FormInfo (from the Sybex MSAccess Developers Handbook by Ken Getz) for various ways you can also manipulate a form.

    *** If after downloading, the MSAccess file doesn't open, make sure to add this website to your intranet security in IE before downloading to then be able to open any MSAccess files within a zip download.

    .
    Last edited by pkstormy; 08-27-2010 at 08:31 PM.

  2. #2
    blindhawkeye is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2011
    Posts
    3

    Thumbs up Great Form and Script

    Ok so I got the form and scripts into my database, but cannot seem to get it to write to a table. A want to basicly make a timestamp everytime some looks at the database. Also been trying to make it load right at the begining, but cannot seem where to find to put the code to make it load right at the begining.

  3. #3
    weshader is offline Novice
    Windows XP Access 2003
    Join Date
    Nov 2009
    Posts
    3
    This works great by the way. However, I am using this along with some other code to check the number of connections to my back end database and list the computer name, user, connected, etc...

    My back end database is stored on a network share.

    When I run this function it brings back the user name local to the PC it is running on instead of the user name of the connection. Any ideas on how to tweek this so that it will return what I want?

    Thanks!

  4. #4
    YellowMetal is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2011
    Posts
    2

    Avoiding Undefined function 'Environ'

    The code in the zipped MDB file by PKStormy worked fine on my 32-bit Access in 64-bit Win 7. When I incorporated the code for GetUser into my MBD, my MDB failed with: Undefined function 'Environ' in expression.

    I searched my MDB file using WordPad and could not find Environ("username") which I used prior to Access 2010. The only text "environ" was as part of sentences each of which had the full word "environment", not a function or subroutine.

    Is is possible to get the GetUser() function to work on 32-bit versions of Access 2000, 2002, 2003, d007 and 2010? I need the UserId to determine what the user is authorized to do before showing any screens.

  5. #5
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    Environ works just fine for me on all versions of Access. But the thing to note is that in Windows 7 (or Vista) you may need to modify it to this:

    VBA.Environ("username")

  6. #6
    YellowMetal is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2011
    Posts
    2

    Added a splash start-up screen to isolate problem

    Thank you. The problem turned out to be a query with the text
    userid=environ("username")
    as part of a SQL expression. I found the problem by inserting a start-up splash screen which showed the user's Windows network sign in and then quit.

    I was not able to use VBA.Environ or any text like Environ and have the Access application work on 32-bit Access 2010.

  7. #7
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    Quote Originally Posted by YellowMetal View Post

    I was not able to use VBA.Environ or any text like Environ and have the Access application work on 32-bit Access 2010.
    Strange because I have Windows 7 64 Bit at home and use 32 bit Access 2010 and can use it with no problem.

  8. #8
    pkstormy's Avatar
    pkstormy is offline Access/SQL Server Expert
    Windows XP Access 2003
    Join Date
    Mar 2010
    Location
    Madison
    Posts
    682
    Try using the method which utilizes the SystemInfo class module. I found this method works when the environ method doesn't or if the user is logging into the computer with their loginID but the 'real' loginID to the computer is another LoginID. For example, we used to have things setup at work where everyone was actually logging into their computer (behind the scenes) as "dom-user" versus what their actual LoginID even though each user logged in with their own LoginID. Hence when using the environ method, it always returned 'dom-user' regardless of what the user's LoginID was. Using the SystemInfo class module would allow me to grab their actual loginID versus the 'behind the scenes/masked' loginID.

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

Similar Threads

  1. Object doesn't support property or method
    By Jamy in forum Programming
    Replies: 7
    Last Post: 07-15-2013, 01:42 AM
  2. Which method is better?
    By undrcvr in forum Database Design
    Replies: 3
    Last Post: 05-24-2010, 12:46 PM
  3. trnsferspreadsheet method - no data
    By Lurmis in forum Programming
    Replies: 5
    Last Post: 09-24-2009, 08:51 AM
  4. Common Dialog control / ShowOpen method
    By phuile in forum Forms
    Replies: 0
    Last Post: 04-10-2009, 12:16 AM
  5. Replies: 2
    Last Post: 02-28-2009, 03:31 PM

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