Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2007

    Unanswered: checking to see if Environ$("username") is in a list of users

    Hi there.
    I have splash form that loads first when my access db starts up. I'd like to add logic to check if the user is in my list of valid users.
    I've tried to use the DoCmd.RunSQL command but I've learned from reading some older posts here that you can't use it to select statements - its only for active commands.
    So.. the other idea I had was to try to bind a drop down list to the form and loop through it for an entry that matches Environ$("username"). But that doesn't seem like good design either because if the list of usernames grows, i don't want to loop through everything each time.
    I didn't see any cbmoUsernames.Exists() method that would let me just try a matching string.
    Any suggestions would be appreciated. I apologize in advance if I'm missing something obvious- still a ms access forms newbie.


  2. #2
    Join Date
    Jan 2007
    Provided Answers: 12
    Ok, first off:

    Do you know how easy it is to fake the Environ("Username")? Trust me, it is!

    If you're determined to do it this way then what you should do is open a recordset with code similar to this
    Dim sql As String
    If Nz(Environ$("Username") , "") <> "" Then
         sql = "SELECT 937 FROM userTable WHERE userName = '"
         sql = sql & Environ$("Username")
         sql = sql & "'"
    End If
    Home | Blog

  3. #3
    Join Date
    Jul 2007

    faking Environ username

    Really? Interesting... I'll have to do some reading on that.
    Thanks for the tip.

    RE: your code snippet, do i save this to a DAO recordset of some sort? and how do i execute the sql? I just learned that I can't use the docmd.runsql command...
    Last edited by chubbypama; 01-20-08 at 23:02.

Posting Permissions

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