Results 1 to 8 of 8
  1. #1
    fletcjas is offline Novice
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2018
    Location
    Lincoln, UK
    Posts
    23

    Login restrictions

    Hello


    I'm not sure if this is the right thread, but here is my question.
    I have a database that requires users to login.
    I have 2 tables:
    DBUsers - This holds users data such as username, password and security level
    Security Levels - This holds the list for the security levels eg 1 = admins, 2 = Users, 3 = Reports Only

    At current, when a user logs in the code runs as follows:
    Code:
    UserLevel = DLookup("UserSecurity", "DBUsers", "UserName = '" & Me.TxtLoginID.Value & "'")
            TempPass = DLookup("password", "DBUsers", "UserName = '" & Me.TxtLoginID.Value & "'")
            ID = DLookup("UserID", "DBUsers", "UserName = '" & Me.TxtLoginID.Value & "'")
            If (TempPass = "password") Then
            Me.TxtLoginID.Value = ""
            Me.TxtPassword.Value = ""
            Me.InfoWrong.Visible = False
                MsgBox "Please provide a new secure password.", vbInformation, "New Password Required"
                DoCmd.OpenForm "frm_Admin_UpdateDBUsersInfo", , , "[UserID] = " & ID
            Else
                ' Admin Users
                If UserLevel = 1 Then
        Call CreateSession(LngUserID)
        Call LogMeIn(LngUserID)
                DoCmd.Close
                DoCmd.OpenForm "frm_Login_MAdmin_Portal"
                DoCmd.OpenForm "frm_Admin_InactiveShutDown", , , , , acHidden
                    Exit Sub
            Else
                'General Users
                If UserLevel = 2 Then
        Call CreateSession(LngUserID)
        Call LogMeIn(LngLoginId)
                DoCmd.Close
                DoCmd.OpenForm "frm_Login_GAdmin_Portal"
                DoCmd.OpenForm "frm_Admin_InactiveShutDown", , , , , acHidden
                Exit Sub
            Else
            'Reports Only Users
                If UserLevel = 8 Then
        Call CreateSession(LngUserID)
        Call LogMeIn(LngUserID)
                DoCmd.Close
                DoCmd.OpenForm "frm_Admin_InactiveShutDown", , , , , acHidden
                DoCmd.OpenForm "frm_MainPages_Reports"
                Exit Sub
    Click image for larger version. 

Name:	cc.PNG 
Views:	38 
Size:	28.8 KB 
ID:	35446
    I have a login form that is different for each user type, I am looking at having just one form, and each button is controlled by a level access, so level one can have all buttons/tabs, but level 3 can have some, If this makes sense.

    I am happy to create a new table if required, this could also be controlled by 'tick' boxes.

    Thanks in advance.

    Jase

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    I do this. Code in form Open event sets visibility of controls based on user permissions.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    fletcjas is offline Novice
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2018
    Location
    Lincoln, UK
    Posts
    23
    Hey June7,Thank you for the reply.
    How would I pass through the security level value to the menu? I'm guessing it would be something like:
    Code:
    If VALUE = 1 then
    me.button.enabled = false
    me.button.enabled = true
    me.button.enabled = false
    me.button.enabled = false
    else
    If VALUE = 2 then
    me.button.enabled = false
    me.button.enabled = True
    me.button.enabled = false
    me.button.enabled = True
    ......
    Would i need to have the value displayed somewhere for this?

    Thanks again

    Jase

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    I have user info on a form that never closes - MainMenu - so it is always available for reference. MainMenu is BOUND to Users table and Login procedure opens filtered to user.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    fletcjas is offline Novice
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2018
    Location
    Lincoln, UK
    Posts
    23
    Hey June7,
    Thank you for the reply, but how would this be done? I have a form that is hidden (used for a logout timer, so if the form is left 5 mins it will auto logout) I am happy to add fields to this.

    Thanks

    Jason

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Auto logout - you close the database?

    Discussion on same topic and my code can be viewed in https://www.accessforums.net/showthread.php?t=23585
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    fletcjas is offline Novice
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2018
    Location
    Lincoln, UK
    Posts
    23
    Hey again.
    I have it so when the users login, and leaves the database for a short time, it auto logs out.
    This isn't the issue or the question i have asked, I am looking for a way to set the navigation buttons based on a users access level..
    So could i have it so all buttons are referenced on the open form (hidden) for example:

    Button 1 = true THEN button 1 on the form would be enabled..?

    Thanks

    Jase

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Did you review the link? Sorry my post was not clear. The reference has nothing to do with timeout of form. See post 4 of that thread.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. comboBox restrictions
    By ShostyFan in forum Access
    Replies: 3
    Last Post: 01-21-2017, 05:18 PM
  2. Replies: 1
    Last Post: 07-08-2014, 01:47 PM
  3. restrictions for different users
    By joe1987 in forum Access
    Replies: 7
    Last Post: 12-11-2011, 05:05 PM
  4. help with creating data restrictions
    By aburaed in forum Access
    Replies: 3
    Last Post: 08-30-2011, 05:41 PM
  5. Form Restrictions
    By Evgeny in forum Forms
    Replies: 4
    Last Post: 04-22-2010, 03:50 PM

Tags for this Thread

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