Setting up pw for Admin, but no login for general users?

simpleton

Registered User.
Local time
Today, 16:14
Joined
Jul 7, 2008
Messages
21
Is there a way I can setup general user's to only see the Main form (without using a login/pw) and set a password for Admin's so they can get access to everything?


Here's what I have:

I created a little access db so that users can get data onscreen. I have their form setup to auto-start and disable everything else.

We have two admins here that want to be able to go into the backend for editing the data. So, I currently have it so all they have to do is open the DB by <Shift> <Click> and then navigate to their little "Admin Tool" form I created. But, they are wanting a password protection too.... uhg...

I'd love any thoughts on this...
 
hi,

You could just do something simple like add a condition when the button is pressed-
Code:
Sub MyPwFormButton_Click()
Dim strPw1 As String
Dim strPw2 As String
Dim strAdmin As String
Dim strAdminChk As String
Dim strPwChk As String

strAdmin = "Admin"
strPw1 = "YourPw1"
StrPw2 = "YourPw2"

strAdminChk = Me!MyUserName
StrPwCheck = Me!MyPw

If strAdminChk <> strAdmin Then
Msgbox ("you have not entered the correct name")
Me!MyUserName.Value = ""
Exit Sub
Else
If strPwChk <> strPw1 Or strPw2 Then
Msgbox ("you entered an incorrect password")
Exit Sub
Else
DoCmd.Close A_Form.Name
DoCmd.OpenForm "YourAdminForm"
End If
End If
End Sub

You could place the fields on a form with a button. Place the code on the buttons OnClick event, change the form objects in the code to the relavent forms.

When the button is clicked, the fields are checked. If the admin name and passwords match, success. If not, boot out.

Regs

Nigel
 
Awesome. That looks perfect. I'll try it Monday.
Thank you, thank you.
 
Hello mate,

re looked at my code as it was a bit wrong!
( thats what happens when you try and help whilst using a phone with a very small screen.... )

anyway,

attached is a db in 2007 format and here is the main code below-

Code:
    Dim strPw1 As String
    Dim strPw2 As String
    Dim strAdmin As String
    Dim strAdminChk As String
    Dim strPwChk As String
    strAdmin = "Admin"
    strPw1 = "LetMeIn1"
    strPw2 = "LetMeIn2"
    strAdminChk = Nz(Me!MyUserName, "")
    strPwChk = Nz(Me!MyPW, "")
    If strAdminChk = "" Then
        MsgBox ("You have not entered a username!")
        Me!MyUserName.SetFocus
        Exit Sub
    Else
        If strAdminChk <> strAdmin Then
            MsgBox ("you have not entered the correct name")
            Me!MyUserName.Value = ""
            Exit Sub
        Else
            If strPwChk = "" Then
                MsgBox ("you need to enter a password!")
                Me!MyPW.SetFocus
                Exit Sub
            Else
                Select Case strPwChk
                Case strPw1
                    DoCmd.OpenForm "youradminform"
                    MsgBox ("Welcome to Admin " & vbCrLf & _
                    "UserName = : " & strAdminChk & vbCrLf & _
                    "Password = : " & strPw1)
                    DoCmd.Close acForm, Name
                    DoCmd.OpenForm "YourAdminForm"
                    Exit Sub
                Case strPw2
                    DoCmd.OpenForm "youradminform"
                    MsgBox ("Welcome to Admin " & vbCrLf & _
                    "UserName = : " & strAdminChk & vbCrLf & _
                    "Password = : " & strPw2)
                    DoCmd.Close acForm, Name
                    DoCmd.OpenForm "YourAdminForm"
                    Exit Sub
                Case Else
                    MsgBox ("You have entered an incorrect password")
                    Exit Sub
                End Select
 
            End If
        End If
    End If

if you want it in .mdb, let me know



NS
 

Attachments

Ok. That worked quite well.
Thanks sooo much!!

I tweaked it a little bit so it only asks for PW. And doesn't give the reply.
Thanks a lot!
 
Ha Ha,

i never use the reply messages, only put them in to give an example of exit.

Regs,

Nigel
 

Users who are viewing this thread

Back
Top Bottom