Page 1 of 2 12 LastLast
Results 1 to 15 of 20
  1. #1
    hinchi1 is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Sep 2017
    Posts
    181

    User access via Logon screen

    I know how to create and setup tables for a logon form, and also create the form itself. The DB I have only has two forms, so not too big. What I would like to do is when the user logs in to the DB, check what access they have and only allow the user to see the records that are relevant to them when they open the staff form.



    Database Admin can see all data
    Users can only see, edit records of the staff they manage
    When form is opened the data is filtered to the user access level

    Thanks in advance.

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    So what are you asking?
    It would all depends on what the structure of your DB is?

    Do you have a way of identifying a user and the records they should see?
    If not, you are out of luck.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,566
    Hi

    The attached is a very good method produced by Vlad.
    Attached Files Attached Files
    You can PM me if you need further help.
    Good Reading https://docs.microsoft.com/en-gb/off...on-description

  4. #4
    hinchi1 is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Sep 2017
    Posts
    181
    Thank you very much

  5. #5
    hinchi1 is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Sep 2017
    Posts
    181
    Quote Originally Posted by Welshgasman View Post
    So what are you asking?
    It would all depends on what the structure of your DB is?

    Do you have a way of identifying a user and the records they should see?
    If not, you are out of luck.
    When the user logs on, using TempVars I can identify their user ID and use this to filter records. Just not sure of the best way to do this.

  6. #6
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    use this to filter records
    not a good idea to filter records - a user can remove the filter. Better to apply a criteria to the form's underlying recordsource

  7. #7
    hinchi1 is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Sep 2017
    Posts
    181
    How do I do this?

  8. #8
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    Filtering data is different form the usual "access levels" concept which is used in general to restrict access to certain functionality\controls on forms based on the current user's level. To filter data you would use some sort of criteria in the form's recordsource query to restrict the query's records; for example you would add the user table to the recordsource, join the UserID from it to the UserID field in the data table you want to restrict, bring the UserLevel (or UserRole or whatever you call it) in the query and put Like Forms!frmLogon!UserRole (assumes you hide the logon form so it stays open or use the tempvar approach and reference that). For a regular user set the hidden control to a certain value and for Admin set it to "*" so they can see everything.

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  9. #9
    hinchi1 is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Sep 2017
    Posts
    181
    Do you have any examples please?

  10. #10
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    there are a number of ways to accomplish what you want. Which way is appropriate depends on what you have. And you haven't thought to tell us what that is

    You understand what joins are, so what don't you understand about Gicu's suggestion?

  11. #11
    hinchi1 is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Sep 2017
    Posts
    181
    Thanks for the reply. I will remove sensitive data and post the database as is tomorrow. That should make it clear, hopefully.

  12. #12
    Amicron's Avatar
    Amicron is offline Access Guru
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Amherst, New York (near Buffalo)
    Posts
    31
    This is how I do it: User Level Security

  13. #13
    hinchi1 is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Sep 2017
    Posts
    181
    Thanks Amicron
    I watched this today, very useful. I'm probably over thinking this. Will give it some more thought this next week.

  14. #14
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2013 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,115
    @amicron - what you're showing is what I mentioned in my original post - controlling what a certain user can do (open forms, click buttoms, view textboxes, etc.). I have a free utility that does that using a custom system table so it uses record based "access rules" rather than VBA hardcoded rules.
    https://forestbyte.com/ms-access-uti...access-levels/
    What the OP wants is a totally different thing, the need here is to restrict data to a certain subset (so for example a manager can see only their department data). You mention that your third video is showing how to restrict the data for the current user's own records (probably by storing that in the table with a default from the login form), which is closer to what OP wants but still not quite. Restricting data can only be done by manipulating the form's (or report's) recordsource. With an Access back-end that can only be done by criteria in a query; for SQL Server, MySQL, Oracle and similar you can use views in the back-end to enforce the data based on the login permissions.

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  15. #15
    hinchi1 is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Sep 2017
    Posts
    181
    Hi Gicu
    Thanks for this. The DB is very basic and doesn't require too much security. I will look at this tomorrow, hopefully I will understand it.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Need help with VB Logon Screen
    By tmb842 in forum Access
    Replies: 6
    Last Post: 12-27-2016, 06:16 AM
  2. Multi User Logon: Check Box = Diffrent Forms
    By Zantox in forum Programming
    Replies: 7
    Last Post: 11-11-2012, 01:01 PM
  3. Replies: 1
    Last Post: 02-25-2012, 01:14 PM
  4. Logon Error on access
    By jhargram in forum Security
    Replies: 5
    Last Post: 02-24-2012, 05:36 AM
  5. Replies: 0
    Last Post: 09-27-2011, 12:25 PM

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