Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

More form Locking

Status
Not open for further replies.

newbieone

Technical User
Jan 3, 2006
50
US
I was helped yesterday in locking the form so an enduser could not update the record. Now I need to know the best way to lock only certain fields on the form while allowing others to remain editable. I am thinking a subform will have to be created with these fields or possibly setting the focus.
 
You can set the lock property for each control to yes if you want to prevent the user from being able to change the value in the field that is the data source for that control.

If you want to selectively lock the controls based on the user's rights within the application, you will need to do that in code. Initially you should set all of the controls involved so that locked is "yes". Then, when the form is loaded, check the user's rights and if the user should be able to edit some or all of those fields set each field's locked property to false/no.

me.mycontrol.locked = false


Bob
 
How do you check someone's rights within the code? Do I have to set security for the database using the security wizard in access in order to initially set a users rights? Can you give me an example?
 
I don't use the Access workgroup security because I've found more problems when using it that I care to deal with, especially when you want to upgrade a database (including conversion of the data to SQL Server).

Normally I set up a login form that uses a table (UserList) that includes the login information as well as the user names and rights. If you create a module where you define some public variables such as strUserID, strUserRights, you can then check the value of strUserRights (or whatever public variable you use) to determine what you want a user to see or be able to edit on a form.

For example, if you want to make a function that is accessed through a command button on a form available only to users with the rights = "Admin", you would do something like this for the on open property of the form:

if strUserRights = "Admin" then
' make command button visible
me.cmdSpecialFunction.visible = True
else
' hide command button
me.cmdSpecialFunction.visible = False
end if



Bob
 
so setting up security would be a login table with the user name and rights. the code would look at the table determine where that user resides then run the correct part of the code. Is there defaults for each right or can I create my own rights and what I want the end user to see?


for example:

User xyz has "data" rights and therefore can only enter data but not delete or view special functions.

I would think that this security would allow me to make visable or not visable a whole tab on a form correct?
 
You could even decide whether to allow edits, additions, etc. for the form. There are no defaults. You create your own rules. The trick is when you set up the form make the properties of the form, controls, etc., whatever would be the most restricted results.

Bob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top