|
security
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
User Defined PermissionsI need to lock a text box in a Microsoft Access Database, however I only need
to lock it from a specific user group. Ideally I could just set a permission, but it's not a listed permission. I've tried to disable it from the form and it says that I can't disable a control while it has the focus. I went into Design View and tried to change it there, but it says that the property cannot be modified because it is in a linked table. Please don't tell to unlink and relink the tables, because I have doubts as to my ability to do so. In the security controls there are user defined permissions and theoretically I could define one to control that text box and then just set the permission for the user group and read only-disabled. However, I've never done that before and am afraid to try. My boss is getting really cranky that I haven't locked it already, somebody please help!! Chandra,
What you want to do can only be accomplished by creating some custom code in VBA. If you have users set up and have everyone logging into the database successfully, then you can simply use the CurrentUser function in the Current event of your data entry form to set the Locked and/or Enabled property of the textbox. -- Show quoteLynn Trapp MS Access MVP www.ltcomputerdesigns.com Access Security: www.ltcomputerdesigns.com/Security.htm Jeff Conrad's Access Junkie List: http://home.bendbroadband.com/conradsystems/accessjunkie.html "Chandra" <Chan***@discussions.microsoft.com> wrote in message news:BFCAD3F6-6FA5-4A6E-9CF3-C81D6BA39416@microsoft.com... >I need to lock a text box in a Microsoft Access Database, however I only >need > to lock it from a specific user group. Ideally I could just set a > permission, but it's not a listed permission. I've tried to disable it > from > the form and it says that I can't disable a control while it has the > focus. > I went into Design View and tried to change it there, but it says that the > property cannot be modified because it is in a linked table. Please don't > tell to unlink and relink the tables, because I have doubts as to my > ability > to do so. In the security controls there are user defined permissions and > theoretically I could define one to control that text box and then just > set > the permission for the user group and read only-disabled. However, I've > never done that before and am afraid to try. My boss is getting really > cranky that I haven't locked it already, somebody please help!! Is the text box bound to a field in a table or query? If it is, then aren't
you really trying to secure the data in the field from the user group? Lynn's solution is technically correct since you said that you wanted to secure a text box. If you answered yes to the questions above, you need to be aware that a user can still affect the data in the field to which the text box is bound after implementing her solution. The only way to do what I suspect you wish to accomplish is with a query delcaring WITH OWNERACCESS OPTION. Lynn's solution would probably stop most users; WITH OWNERACCESS OPTION would stop anyone not capable of defeating (hacking) MS Access security. Maybe most is enough as long as the boss knows what is invloved. Solving the problem with owner access queries is kind of involved. To implement the owner access solution you would need to remove the user group's update and insert permissions on the field's table. When the user group needs to update or insert, the group would do so be means of a query with the owner access declaration that does not expose the field and is owned by a group or user with permissions to update and insert. I agree with John & Lynn. But if you want a "quick & dirty" solution,
which just locks the textbox on the form, put this in the code behind your form: (UNTESTED) private sub form_open() dim s as string me.selheight=1 on error resume next s = dbengine(0).users(currentuser).groups![THEBADGROUP].name me![MYTEXTBOX].enabled = (err.number <> 0) on error goto 0 me.selheight=0 end sub The above (UNTESTED) code will lock the textbox named MYTEXTBOX if, and only if, the current user is a member of the group named THEBADGROUP. I can't remember whether the form_open procedure has a cancel parameter, or not. If the code is rejected with an error similar to "procedure does not match prototype", just change form_open to form_load & it should be ok. ( If anyone reading is curious about the me.selheight, that's a useful method of ensuring that the focus is not on any particular field. So in particular, it will not be on the textbox field and thus prevent disabling that field. The second selheight moves the focus back to the first enterable field in tab order. This technique does /not/ require the form to have any record-selectors. ) HTH, TC |
|||||||||||||||||||||||