#1
  1. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Jul 2012
    Posts
    18
    Rep Power
    0

    Adding Security help


    i know that u can add security with MySQL

    but for my problem, i need to create a form in microsoft access with security which i can't find any help on google

    Question: You are requested to plan and develop an access control for the users of this application, enabling users only to access the following individual forms if they have been given permission.

    The following list describes user roles and which forms they are allowed to access or are allowed only for “Read Only” view:

    how do i actually add securitys to a form??

    Develop a main form for the application which contains:

    • Clickable buttons to the forms listed above, that open their corresponding forms with the suitable permission (Read/Write or Read Only).
    o The buttons should be organized in a comprehensible way (single column, multiple columns, multiple rows, etc).
    o Buttons for forms which the user doesn’t have access permission, should not be shown.
     If a button is not available for the current user then the next buttons must cover its space automatically.
    o “Read Only” access buttons should appear different from Read/Write access buttons.
  2. #2
  3. Contributing User
    ASP Adventurer (500 - 999 posts)

    Join Date
    Jun 2011
    Location
    South Jersey
    Posts
    544
    Rep Power
    59
    Homework?

    It's not really security, you're just changing the attributes of the form, or the visbile properties of certain controls based on the user. To add "Security" to a single form usually involves a bunch of vba in the onload event of the form.

    Please post specific questions as you come to problems. Generally posts that sound like homework don't get a lot of help unless you are very specific in your questions. (Sorry, How do I do this? is not specific enough.)
  4. #3
  5. Contributing User
    ASP Adventurer (500 - 999 posts)

    Join Date
    Feb 2008
    Location
    Lake County, IL
    Posts
    865
    Rep Power
    152
    Here is a link that you may find helpful in determining how to achieve your goal

    Tutorial -- An Access menu / permissions system
    Alan Sidman
    Office 2010, 2007, 2002

    If I helped you, then click "give rep" button in the lower left corner.
  6. #4
  7. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Jul 2012
    Posts
    18
    Rep Power
    0
    Originally Posted by alansidman
    Here is a link that you may find helpful in determining how to achieve your goal

    Tutorial -- An Access menu / permissions system
    thanks a lot alan,

    but i need some help here regarding Private Sub Form_Load()

    It just keep giving me "Compile Error: Sub or Function not Defined" and highlights Private Sub Form_Load

    i don't understand why it keeps saying error on that form_load everytime i create or recreate a new one to try to remove this error.

    i just followed the tutorial by putting the codes in the Private Sub Form_Load but it just won't work when i put in form view. telling me that it's not defined...
  8. #5
  9. Contributing User
    ASP Adventurer (500 - 999 posts)

    Join Date
    Feb 2008
    Location
    Lake County, IL
    Posts
    865
    Rep Power
    152
    Have you created the Get Permission Function? The code will bomb out with out this function as there is a call for it in the code. Compare your code to mine which works in a db currently

    Code:
    Private Sub Form_Load()
        Dim sPermit As String
        Dim iAccess As Integer
        Dim Ctl As Access.Control
        Me.txtUser = Environ("username")
        If isNothing(Me.txtUser) Then
            sPermit = "ReadOnly"
        Else
            sPermit = GetPermission(Me.txtUser)
        End If
        Select Case sPermit
            Case "Edit"
                iAccess = 2
            Case "Admin"
                iAccess = 3
            Case Else
                iAccess = 1
        End Select
        Me.txtLevel = iAccess
        Me.LstMenu.Requery
        
            
    End Sub
    
    Private Function GetPermission(sUser As String)
        If (isNothing(DLookup("Permissions", "tblStaff", "Login='" & Forms!frmMainMenu!txtUser & "'"))) Then
            GetPermission = "ReadOnly"
        Else
            GetPermission = DLookup("Permissions", "tblStaff", "Login='" & Forms!frmMainMenu!txtUser & "'")
        End If
    End Function
    You will naturally have different table and field names.
    Alan
    Last edited by alansidman; January 10th, 2013 at 10:23 PM. Reason: Added Code
  10. #6
  11. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Jul 2012
    Posts
    18
    Rep Power
    0
    Originally Posted by alansidman
    Have you created the Get Permission Function? The code will bomb out with out this function as there is a call for it in the code. Compare your code to mine which works in a db currently

    Code:
    Private Sub Form_Load()
        Dim sPermit As String
        Dim iAccess As Integer
        Dim Ctl As Access.Control
        Me.txtUser = Environ("username")
        If isNothing(Me.txtUser) Then
            sPermit = "ReadOnly"
        Else
            sPermit = GetPermission(Me.txtUser)
        End If
        Select Case sPermit
            Case "Edit"
                iAccess = 2
            Case "Admin"
                iAccess = 3
            Case Else
                iAccess = 1
        End Select
        Me.txtLevel = iAccess
        Me.LstMenu.Requery
        
            
    End Sub
    
    Private Function GetPermission(sUser As String)
        If (isNothing(DLookup("Permissions", "tblStaff", "Login='" & Forms!frmMainMenu!txtUser & "'"))) Then
            GetPermission = "ReadOnly"
        Else
            GetPermission = DLookup("Permissions", "tblStaff", "Login='" & Forms!frmMainMenu!txtUser & "'")
        End If
    End Function
    You will naturally have different table and field names.
    Alan
    Everything is the same as yours, i folo how they make putting only 2 text box naming the same as those but still whenever i open in form view. it just keep asking me to define it and highlight that Private Sub Form_Load()
  12. #7
  13. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Jul 2012
    Posts
    18
    Rep Power
    0
    well, i didn't find any button to edit my post,

    I noticed that when i tried saving it asked me to whether if i want to save change on Menu and Drug Test Selection(This is another form with codes including Private sub Form_Load() )

    is it because both of them are together? how do i separate this 2 form
  14. #8
  15. Contributing User
    ASP Adventurer (500 - 999 posts)

    Join Date
    Jun 2011
    Location
    South Jersey
    Posts
    544
    Rep Power
    59
    Can you paste the complete code from that private sub, so that we can take a look? Make sure you check the spelling of all functions you are using within the code.
  16. #9
  17. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Jul 2012
    Posts
    18
    Rep Power
    0
    Originally Posted by meratigoerr
    Can you paste the complete code from that private sub, so that we can take a look? Make sure you check the spelling of all functions you are using within the code.
    it's solved. forgot to add the last code in it. that's why isnothing isn't defined >.<

    but still i don't really know how the menulist works ._.
  18. #10
  19. Contributing User
    ASP Adventurer (500 - 999 posts)

    Join Date
    Feb 2008
    Location
    Lake County, IL
    Posts
    865
    Rep Power
    152
    Can you be more specific? Are you having an issue?
    but still i don't really know how the menulist works
  20. #11
  21. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Jul 2012
    Posts
    18
    Rep Power
    0
    Originally Posted by alansidman
    Can you be more specific? Are you having an issue?
    I'm so stress now.. i'm not good at this kind of stuff

    in form View, the listbox shows the items but after clicking on 1 of the item in listbox it shows "compile Error: Method or Data Member not found"
    "It does not require the users to log in: their Windows login name is captured" << what i want is to log in on each user, and only a few user can view some forms and read only. i don't want it to be my windows login name...

    Dim sForm As String, sType As String
    sForm = Me.lstMenu.Column(1) <<< highlights 1stMenu The name is correct
    sType = Me.lstMenu.Column(2)
    Select Case sType
    Case "Form"
    DoCmd.OpenForm sForm
    Case "Report"
    DoCmd.OpenReport sForm, acViewPreview
    End Select
  22. #12
  23. Contributing User
    ASP Adventurer (500 - 999 posts)

    Join Date
    Feb 2008
    Location
    Lake County, IL
    Posts
    865
    Rep Power
    152
    Suggest you post the question back to the originator of the code as he may have an alternative solution.

Similar Threads

  1. Adding security to a MSAccess DB
    By cokie69 in forum ASP Development
    Replies: 0
    Last Post: February 23rd, 2008, 03:42 PM
  2. Currency change aimed at adding security (AP)
    By RSS_News_User in forum Technology News
    Replies: 0
    Last Post: August 26th, 2007, 12:05 PM
  3. Currency change aimed at adding security (AP)
    By RSS_News_User in forum Technology News
    Replies: 0
    Last Post: August 26th, 2007, 09:03 AM
  4. Homeland Security to host closed-door security forum (PC World)
    By RSS_News_User in forum Technology News
    Replies: 0
    Last Post: June 28th, 2007, 09:03 PM
  5. Replies: 3
    Last Post: July 27th, 2004, 10:06 AM

IMN logo majestic logo threadwatch logo seochat tools logo