How can a user's login determine which switchboard opens?

C

Chris v.

Please advise me if this is not the best way to accomplish the desired
result. I am new to Access and have very limited programming experience. I'm
creating a split database. There will be several users with different
permissions to use the database: 1) View ONLY, 2) Enter data using only a
FEW fomrs, 3) Enter/Edit any data using forms, and 4) Administrator (Full
Access to create new queries/forms and edit tables if necessary). I would
like the users to log on the the database as the agency only uses a file
server (this will hold the back-end, and I will install the front-end along
with Access runtime on the local boxes). I'm thinking that there could be a
switchboard for each permission level, which would load after a log-in form
is completed. The different switchboards would all be copies of the main
switchboard, but with comand buttons disabled (and grayed) per users access
to the database. So I have 2 questions: 1) Is this a workable plan and 2) How
do I load the correct Switchboard once log-in is completed? I've only used
macro's so far (I have no VB experience).
 
S

Stefan Hoffmann

hi Chris,
So I have 2 questions: 1) Is this a workable plan and 2) How
do I load the correct Switchboard once log-in is completed? I've only used
macro's so far (I have no VB experience).
1) Yes, you may go this way. But keep in mind, that a "power" user can
bypass these measures.

2) You need a table holding the users and their passwords (better
encrypted passwords or hashes) for the login. Add a field for the access
level using fixed lookup values. Simply name your switchboards after
them, e.g.

Switchboard_ReadOnly
Switchboard_..
Switchboard_Administrator

Then you may use something like this for your login form:

Private Sub cmdLogin_Click()

Dim AccessLevel As Variant
Dim Condition As String
Dim Password As String
Dim Username As String

Password = "'" & Replace(Nz(txtPassword.Value, ""), "'", "''") & "'"
Username = "'" & Replace(Nz(txtUsername.Value, ""), "'", "''") & "'"
Condition = "Username = " & Username & " AND Password = " & Password"

AccessLevel = DLookup("AccessLevel", "User", Condition)
If IsNull(AccessLevel) Then
MsgBox "Wrong credentials."
Else
DoCmd.OpenForm "Switchboard_" & AccessLevel
DoCmd.Close acForm, Me.Name
End If

End Sub

mfG
--> stefan <--
 
B

Barry A&P

Chris

Here is a little youtube Tutorial that shows how to do the user logon
although the suggestion stefan made with the table seems like the best
route..
There are a few other videos by the same poster that add a little more
functionality to the logon form..

Barry
 

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