Access Security

A

ahpitre

Currently have a database where the user logs in his username and password
(not using workgroup security). If a succesful login is made (user & password
exist on the security table), then user's privileges are read from the table,
and these are used to set permissions for Forms/Reports. I tested 1 form to
enable/disable Additions/Deletions/Edits depending on user's privileges.
Instead of having to code this (On Open Event) for each form, I was wondering
if I could use some Global (Module) code that can be used to Open & set
permissions, then I would not need to code each form, just put 1 line in
Form's On Open Event to call the public Function. I can use the Docmd.Open
form with acEdit or acAdd parameters, but If I want to allow deletions but
not Add/Edit, then I can't do this using the Docmd.OpenForm. Any ideas?
Thanks for the help.
 
S

Scott McDaniel

Currently have a database where the user logs in his username and password
(not using workgroup security). If a succesful login is made (user & password
exist on the security table), then user's privileges are read from the table,
and these are used to set permissions for Forms/Reports. I tested 1 form to
enable/disable Additions/Deletions/Edits depending on user's privileges.
Instead of having to code this (On Open Event) for each form, I was wondering
if I could use some Global (Module) code that can be used to Open & set
permissions, then I would not need to code each form, just put 1 line in
Form's On Open Event to call the public Function. I can use the Docmd.Open
form with acEdit or acAdd parameters, but If I want to allow deletions but
not Add/Edit, then I can't do this using the Docmd.OpenForm. Any ideas?
Thanks for the help.

You can set the form level properties AllowAdditions, AllowDeletions, etc etc, then do something like this:

Public Function SetSecurity(FormName As String, UserName As String) As Boolean

With Forms(FormName)
<set your security here>
.AllowDeletions = UserCanDelete(UserName)
.AllowAdditions = UserCanAdd(UserName)
End With

End Function

Now add this to each form's Open event:

SetSecurity Me.Name

And each form would "set itself" ... the functions like "UserCanDelete" would simply lookup the necessary permissions in
a table and report back to the SetSecurity function. You could also simply open a recordset in the SetSecurity function
which would gather the current user's permissions, then apply them accordingly (I don't know how your permissions are
stored in your tables, so can't advise there).

Scott McDaniel
scott@takemeout_infotrakker.com
www.infotrakker.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top