Results 1 to 11 of 11
  1. #1
    5 Star Lounger
    Join Date
    Nov 2004
    Location
    Wilmington, North Carolina, USA
    Posts
    1,196
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Set combo box value as global variable (Access 2002)

    I've gotten so far as creating a login form based off my tblUsers. I have a combo box that displays the User Names. I need help with a few things. One, after the user selects their user name and enters a password and clicks "Ok", I need to (1) Validate the password, and then (2) Direct them to their specific form. My train of thought is to validate the password in code, and after it passes that, use CASE to direct which form to go to, based on the User Name selected. Next, I need to set that User Name as a global variable (for use in queries/form filters). So far, I've created a module with this:

    Public UserName As String

    I believe somewhere amidst the onclick procedure of the "Ok" button I need code that looks like this:

    varUserName = Me.cboUserName


    help?
    ____________________________
    Jeremy
    "If you spend more on coffee than on IT security, then you will be hacked. What's more, you deserve to be hacked." -Richard Clarke

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

    Re: Set combo box value as global variable (Access 2002)

    It seems you're reinventing the wheel. User-level security is a built-in feature of Access, and it will take care of checking passwords etc. automatically. Moderator <!profile=WendellB>WendellB<!/profile> has a short tutorial on his website, with useful links: The Secrets of Security.

  3. #3
    5 Star Lounger
    Join Date
    Nov 2004
    Location
    Wilmington, North Carolina, USA
    Posts
    1,196
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Set combo box value as global variable (Access 2002)

    Hans,
    I would use User-Level security, and eventually I may, but I'm in need of a quick fix, and I'm designing this database with accessability in mind (read-only queries, etc..).

    Even without using this for security, I still want to use the login form to direct certain people to certain forms....and I will need to set the UserName as the variable.
    Thanks!
    ____________________________
    Jeremy
    "If you spend more on coffee than on IT security, then you will be hacked. What&#39;s more, you deserve to be hacked." -Richard Clarke

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

    Re: Set combo box value as global variable (Access 2002)

    If you use user-level security, CurrentUser is available throughout the database. (If you don't, CurrentUser is always Admin)

    See <post#=198890>post 198890</post#> by <!profile=Support4John>Support4John<!/profile> for a way to set and retrieve global "variables".

  5. #5
    5 Star Lounger
    Join Date
    Nov 2004
    Location
    Wilmington, North Carolina, USA
    Posts
    1,196
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Set combo box value as global variable (Access 2002)

    Hans,
    Thanks for the info <img src=/S/burga.gif border=0 alt=burga width=40 height=15> When I set that variable through "OnClick" on my login form and then my login form closes, does that value remain until the database is opened again?
    ____________________________
    Jeremy
    "If you spend more on coffee than on IT security, then you will be hacked. What&#39;s more, you deserve to be hacked." -Richard Clarke

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

    Re: Set combo box value as global variable (Access 2002)

    The value remains as long as the database is open, but not if the database as a whole is closed and reopened. The user will have to login again.

  7. #7
    5 Star Lounger
    Join Date
    Nov 2004
    Location
    Wilmington, North Carolina, USA
    Posts
    1,196
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Set combo box value as global variable (Access 2002)

    Awesome. Thank you Hans. Now I'm off to find out how to validate my pw.
    Thanks
    ____________________________
    Jeremy
    "If you spend more on coffee than on IT security, then you will be hacked. What&#39;s more, you deserve to be hacked." -Richard Clarke

  8. #8
    5 Star Lounger
    Join Date
    Nov 2004
    Location
    Wilmington, North Carolina, USA
    Posts
    1,196
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Set combo box value as global variable (Access 2002)

    So I go through the Login form and everything, and when I try to do something that works off of the query that filters for just that user's company, I get the error :

    Undefined functin 'username' in expression

    The criteria in my query for company =
    DLookUp("Company","tblUsers","UserName=" & Chr(34) & UserName() & Chr(34))
    ____________________________
    Jeremy
    "If you spend more on coffee than on IT security, then you will be hacked. What&#39;s more, you deserve to be hacked." -Richard Clarke

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

    Re: Set combo box value as global variable (Access 2002)

    I get the impression we're discussing the same subject in two threads at once now. Can I lock one of them, and if so, which one?

  10. #10
    5 Star Lounger
    Join Date
    Nov 2004
    Location
    Wilmington, North Carolina, USA
    Posts
    1,196
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Set combo box value as global variable (Access 2002)

    We are, you're right. Lock whichever...I believe this one is more pertinent...so g'head and lock the other one..here's my last post from it:


    --------------------------------------------------------------------------------
    (this assumes that you have applied user-level security with the usernames and passwords from the table)
    --------------------------------------------------------------------------------



    So I completely missed that. Now that we know I haven't any user level security applied....where do we go from there? (I realize the obvious way would be to apply user level security...that's something I've yet to meddle in, I've secured my database well enough to keep honest people honest so far, and it's worked...)
    ____________________________
    Jeremy
    "If you spend more on coffee than on IT security, then you will be hacked. What&#39;s more, you deserve to be hacked." -Richard Clarke

  11. #11
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,624
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: Set combo box value as global variable (Access 2002)

    I agree with Hans - it appears to me you've spent several hours trying to solve a problem that Access User Security solves. And it only takes about 10 minutes to apply the feature - you start by giving the Admin user a password. To really secure it to the point where it requires a hacker to break into it is more complicated, but even that only takes a couple of hours at the most. If it looks like a wheel, acts like a wheel, and meets your needs, then it must be a wheel.
    Wendell

Posting Permissions

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