Results 1 to 8 of 8
  1. #1
    5 Star Lounger
    Join Date
    May 2003
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    629
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Reading Windows Enviromental Vars ? (2003)

    I thought this would be a FAQ, but I can't seem to find any information on it at all.

    Is there a way for VBA in Access to read Windows environmental variables? Specifically, I want to read the USERNAME variable and use that to set the security levels for the users automatically.

    I realize that this is an easily defeatable and completely non-portable way to handle this, but for my little in-hous projects, it will work just fine.

    Thanks

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

    Re: Reading Windows Enviromental Vars ? (2003)

    You can use the Environ function (it's general VBA, not specific to Access). E.g.

    Dim strUser As String
    strUser = Environ("Username")

  3. #3
    5 Star Lounger
    Join Date
    May 2003
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    629
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Reading Windows Enviromental Vars ? (2003)

    Perfect. Thanks!

    Hey, how come when you type in the exact name of a function into the Access Help, it can't hit on the entry for the function name ?

    Not being able to find things in the documentation is at least as frustrating as anything else.

    Or is it just me? That happens sometime. <img src=/S/blackteeth.gif border=0 alt=blackteeth width=20 height=20>

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

    Re: Reading Windows Enviromental Vars ? (2003)

    The HTML help that Microsoft introduced in Office 2000 is very frustrating (in my opinion). It can be extremely difficult to locate the help item you need.
    I usually type a keyword into the Immediate window and press F1, or use the search function in the Object Browser.

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

    Re: Reading Windows Enviromental Vars ? (2003)

    Charlotte mentioned once (if I remember correctly) that she keeps Access 97 on hand for just the help file. I used to keep '97 loaded for that very same reason (unfortunately, I haven't moved it to my newer computer).
    thx
    Pat

  6. #6
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Reading Windows Enviromental Vars ? (2003)

    Back in Access 2, Microsoft published a book called an Access Language Reference. It is more or less a print out of the help file on all the functions.

    It is still the first place I look!

    Environ is on page 221
    Regards
    John



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

    Re: Reading Windows Enviromental Vars ? (2003)

    Oh, duh! I could use a book! <gg> Funny how that doesn't come immediately to mind, anymore!
    Pat

  8. #8
    5 Star Lounger
    Join Date
    May 2003
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    629
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Reading Windows Enviromental Vars ? (2003)

    Ack! I used that have that manual! I used it when writing some of these databases in Access 95. I must have pitched it some time ago as irrellevant.

    That was before all computer manuals were 1200 page 'Thunk' books that had to have a screen shot of every option page, but often failed to adequately comment on effects of the settings in question, or sometimes even adequately document how to get to that screen.

Posting Permissions

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