Results 1 to 5 of 5
  1. #1
    Lounger
    Join Date
    Apr 2002
    Location
    Salem, New Hampshire, USA
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: need %UserName% (2002)

    Hmmm. I think I may have overlooked the obvious ..... I can probably use CurrentUser, correct?

    Sometimes it just helps to talk out the problem with someone else. Thanks for listening.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: need %UserName% (2002)

    CurrentUser will return the Access username. If you have applied user-level security, so that users have to log into the database with a username and password, that is fine. However, if you have not applied user-level security, CurrentUser will always be Admin (the name of the default user). If you want the Windows username, you can use Environ("username").

  3. #3
    3 Star Lounger
    Join Date
    Jun 2001
    Location
    Salem, Oregon, USA
    Posts
    219
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: need %UserName% (2002)

    Hans, hoping this will work for Rudi. The "environ()" used to return such useful information consistently, and probably still does but at one point, either after Windows 98 or Windows XP, it didn't seem to work any more -- not just in Access, but in a couple of other programs that were using something similar to the "environ()" function. In VB, we shifted over to that API call, the "getusername" (I think) which you and others have so kindly posted here at times. That's been very dependable, whereas the "environ()" may have lost some of it's "charm."

    Thanks for all you do, Hans.

    Pat

  4. #4
    Lounger
    Join Date
    Apr 2002
    Location
    Salem, New Hampshire, USA
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: need %UserName% (2002)

    Just to follow up, the use of Environ appears to be working good with Access 2003 on XP Pro system.
    I am using the following code in a menu OnLoad trigger.
    ----------------------------------------------------------
    Dim strUserName As String

    strUserName = Environ("UserName")

    If strUserName = "admin" Or strUserName = "bill" Or strUserName = "mary" Then
    cmdDisplayDatabaseWindow.Visible = True
    Else
    cmdDisplayDatabaseWindow.Visible = False
    End If
    ----------------------------------------------------------

    Thanks to all for your inputs.

  5. #5
    Lounger
    Join Date
    Apr 2002
    Location
    Salem, New Hampshire, USA
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    need %UserName% (2002) - SOLVED

    How can I get %UserName% from environment variable when database opens and then use that to allow acrivities?

    Example, when Main Menu opens, some buttons should show for UserA and others show for UserB? Other actions would also be controlled by use of %UserName%

    I can handle the code for the visibility, etc., I just need to know how to capture %UserName% ,as some type of global variable, for the session, to use in the IF statements.
    We do not want to use the Access Security tools, just the %UserName%

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •