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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What is the best way to set up security? 1

Status
Not open for further replies.

Mack2

Instructor
Mar 12, 2003
336
0
0
US
The database that I will be appling security too will have 5 users. Each user has their own form that they will be using. They should not have access to the other forms(other departments). How should I set up security? Should I use the wizard? Or, have a user's table, then have the user log in against the table? And if I use the table, do I store their login data into a variable? THANKS IN ADVANCE FOR YOUR TIME!
 
One thing you can do is simply use windows security, if your environment is such that you are comfortable with that. Below is the code from
to get the user name (this is not the only way, but it is one that I have used, and it works). This way, you are confirming the user that is logged into windows, and the security/passowrd that is needed to log into windows. Then just parse your forms against that username, and give them whatever they are eligible for. This way your user doesn't have to log in twice. Of course, this isn't perfect and your environment may not be friendly to this approach.

******************** Code Start **************************
' This code was originally written by Dev Ashish.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' Dev Ashish
'
Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Function fOSUserName() As String
' Returns the network login name
Dim lngLen As Long, lngX As Long
Dim strUserName As String
strUserName = String$(254, 0)
lngLen = 255
lngX = apiGetUserName(strUserName, lngLen)
If ( lngX > 0 ) Then
fOSUserName = Left$(strUserName, lngLen - 1)
Else
fOSUserName = vbNullString
End If
End Function
 
Thanks Chris, I will check it out. How would I parse the forms against the username? Would I store the user in a global variable, and check the variable each time a form opens? THANKS FOR YOUR HELP!
 
What I did was just create a dashboard that changes depending on the username. The only options on it being the ones that are valid for that user (which was stored in a global variable). You would then only need to check when the dashboard was re-opened, and not every form.
 
We want to allow the user's to see all of the data, just not modify it. The global variable makes sense. But how do I handle multiple users logging into the database? Do you store each user into a new global variable? And if so, how would you handle that? THANK YOU FOR YOUR TIME AND HELP CHRIS!!!!!!
 
What you would want to do is define access on a per-form bassis. Something (at the most basic) like this:

Form1 Form2 Form3
Bob True False True
Nancy True True True
Jim False True True

Then you can hide/disable the buttons on the dashboard that link to the disallowed forms.
 
Hi Mack,
I don't know if i have well understood your question.. Usually, i use the "User and Group Permission" and the "User and Group accounts" under Tools->Security in Access 2003.
I think in your case, you can do several groups (each user put it in a unique group) then give group access to the forms the user is allowed to open, modify..
If you like, sometimes i use another way: i make a back-end database, then for each user i create a form, and give him the front-end..
I dont know if you got the 2nd method, anyway, i prefer the first one..
I hope this is what you are seeking..
:)
 
Thanks guys. I ended up using all code, and not the wizard. But I am able to control each form for every user.THANKS!!!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top