Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    HS_1 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2016
    Posts
    107

    Log on form and user rights

    I am a novice at vba , I don’t even know how to start, tried to google it but couldn't find anything which would point me in the right direction,.


    I have Logon form which opens Tracking Form. The Logon formis based on a table TB_User with columns Initial, Password, Group. The form Trackinghas checkbox “chk1” and textbox “txt1_Initial’.
    What I’m try to accomplish is:
    If somebody logged on with admin rights assigned ([Group] = “Admin”) then chk1 box can bechecked and txt1_Initials would be populated with user initials.

    Thanks

  2. #2
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Some of the required information has to be guessed based on your post. Best to provide exact form names, control names, etc, when asking for help that needs to refer to them. To me, it looks like what you need is
    Code:
    If Me.Group="Admin" Then
      With Forms!Tracking
       .chk1 = True
       .txt1_Initial = Forms!Logon.Initial
      End With
    End If
    but I don't know where you should place it. This assumes the form you'd run this from has a control called Group that holds the group value and that both forms are open at the same time.
    Last edited by Micron; 12-25-2016 at 11:05 PM. Reason: clarification
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    HS_1 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2016
    Posts
    107
    Micron thanks for the reply, I don't have control called 'Group' on Tracking Form, the Tracking form reads/writes only from/to Table called "Tracking" and all the controls on the form are related to this table. That is probably the reason why form doesn't recognize Me.Group statement you mentioned above. After I type in user initials and password to the form Logon, it closes and Tracking form opens, only one is open at the same time.
    I found a code on the net and tried to add to the Tracking form under General Declarations to extract values from table TB_Users but have got error "Invalid outside procedure". Frankly I don't know where the user initials who open the database are stored and how to manipulate them to get the desired output.
    Dim dbs As DAO.Database
    Dim rsTable As DAO.Recordset



    Set dbs = CurrentDb

    'Open a table-type Recordset
    Set rsTable = dbs.OpenRecordset("TB_User", dbOpenTable)

  4. #4
    HS_1 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2016
    Posts
    107
    Micron, do you know if there is a way I can zip and send only to you the database, it would be much easier for me to explain what I am trying to accomplish if you see it?
    Thanks

  5. #5
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    What about saving the current (good) version then creating a dud version with wrong user and passwords etc.? Save it as something different incase you need to put it here at a later date?




    Sent from my iPhone using Tapatalk

  6. #6
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Quote Originally Posted by HS_1 View Post
    Micron, do you know if there is a way I can zip and send only to you the database, it would be much easier for me to explain what I am trying to accomplish if you see it?
    Thanks
    I appreciate the vote of confidence and trust but I'm pretty sure that would be against forum rules. As a community of both helpers and those in need of help, we all benefit from the sharing of both problems and solutions. In addition, we're not all lucky enough to be using the latest Access version. I may not be able to open your 2016 db. Andy 49 has the right idea. If possible, saving your db as an .mdb maximizes the number of people who can help.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  7. #7
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    I don't know where the user initials who open the database are stored and how to manipulate them to get the desired output
    If they are not stored but are part of the first form's controls, you can pass data to the opening form by using the openArgs property. In the next form's open event you can test or use the openArgs value being passed. I'm adding this note in case you're not open to the idea of posting your db here, but I think you have nothing to worry about as far as that is concerned.
    Last edited by Micron; 12-26-2016 at 09:57 AM. Reason: grammar

  8. #8
    HS_1 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2016
    Posts
    107

    Logon

    TrForum.mdb
    Micron
    I hope you can see attached dummy dBase. What I try to accomplish is:
    "User1" with Initials "AA" who belongs to group "AAAA" would be able to check boxes Chck_A1 and Chck_A2 but not Chk_B. At the same time his initials should show up in text boxes "TxtA1_Initials" and "TxtA2_Initials" if he choose to check 2 boxes.
    "User2" with initials "BB", group "BBBB" would be allowed to check box "Chk_B" only.
    User "ADMIN" can check all 3 boxes.

    Thanks
    HS_1

  9. #9
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Frankly I don't know where the user initials who open the database are stored and how to manipulate them to get the desired output.
    They are stored at the top of the form module as public variables. Working on it...

  10. #10
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    what if the user unchecks the checkbox? Remove the initials?

  11. #11
    HS_1 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2016
    Posts
    107
    Yes, if he unchecks the box the initials should be removed.
    Thanks for looking into it.
    HS_1

  12. #12
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    This seems to to what you're asking for. Note that public variables in a form module will never be accessible anywhere in the project once you close the form, which is what you were doing upon opening the tracking form. They've been moved to a standard module so that they can be referenced for any other form or user activity. It is possible for them to lose their values if an error is generated, which will require a means of re-establishing them. Right now, you'd have to re-log in. Those variables are referenced by your new form code as the means of setting or removing the initials. I also interpret the locking of check boxes to be something that's done at the user level and that it has nothing to do with the user name. This is not 100% clear in your posts.TrForum.zip
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  13. #13
    HS_1 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2016
    Posts
    107
    Micron
    Thank you very much for your help. This is exactly what I need.
    HS_1

  14. #14
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Glad it does the job. You're welcome.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  15. #15
    HS_1 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jan 2016
    Posts
    107
    Micron
    Sorry for bothering you again. When I plugged in the codes to my database the disabled check boxes based on users rights don't show grey like in the dBase you posted. I was looking for a code and conditional formatting but couldn't find anything related to it. Could you explain briefly how this can be achieved?
    HS_1

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

Similar Threads

  1. Problems with admin rights
    By shod90 in forum Forms
    Replies: 1
    Last Post: 01-07-2016, 06:50 AM
  2. User always appear to connect with exclusive rights
    By kblinkhorn in forum Security
    Replies: 18
    Last Post: 09-02-2010, 01:07 PM
  3. one form fits all rights
    By sugar in forum Programming
    Replies: 4
    Last Post: 06-30-2009, 09:12 AM
  4. account rights
    By pietje in forum Security
    Replies: 1
    Last Post: 02-05-2009, 12:58 PM
  5. Admin Rights
    By Keri in forum Security
    Replies: 4
    Last Post: 11-18-2005, 11:18 AM

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