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

Password attached to a form 1

Status
Not open for further replies.

VicBull

Programmer
Aug 8, 2001
13
GB
Is it possible to attach a password to a form so that it only opens when a passord is typed into a box?
 
You need to have a small login/Password form to do it.
place a textbox(txtPassword) and a command button(cmdOpenForm) add the code to command button's click event
set the textbox's inputmask to password to show asterics only.
Code:
Private Sub cmdOpenForm_Click()
    If Me.txtPassword = "YourPassword" Then
        DoCmd.OpenForm "YourFormName"
    Else
        MsgBox "Wrong password"
    End If
End Sub

________________________________________________________
Zameer Abdulla
Help to find Missing people
My father was a realistic father; not a vending machine dispense everything I demanded for!!
 
Thank you,

Does this code get attached to the form if so where and how is it attached.

Vic

 
This code attached to the "login form" from where you open your original form that need to be protected by password.

Another way to attach code to the original form. Then the code will be like this.
Code:
Private Sub Form_Open(Cancel As Integer)
    Dim strInput As String, strMsg As String

    strMsg = "Enter your password."
    strInput = InputBox(Prompt:=strMsg, _
                        Title:="Form Protected by password", XPos:=2000, YPos:=2000)
    If strInput <> "YourPassword" Then
        Cancel = True
    End If

End Sub
These are the lowest security models.

If you need high protection then have a search for UserGroups/Security/Login in these forums.


________________________________________________________
Zameer Abdulla
Help to find Missing people
My father was a realistic father; not a vending machine dispense everything I demanded for!!
 
Thank you.

Your second idea worked just fine.

It was exactly what I needed.

God bless

Victor

 
Hi just noticed this one. Does this work with Access 2003 Or just 2000.

 
I have tested in Access2002, Won't be any problem with 2003.

________________________________________________________
Zameer Abdulla
Help to find Missing people
My father was a realistic father; not a vending machine dispense everything I demanded for!!
 
I am using this code in 2003 and it works fine.

Vic Bull
 
How could I get this code to open an alternative form if the wrong security code is entered ? Any help appreciated :)
 
Which code you are talikg about?
Here is the one with Inputbox
Code:
Private Sub Form_Open(Cancel As Integer)
    Dim strInput As String, strMsg As String

    strMsg = "Enter your password."
    strInput = InputBox(Prompt:=strMsg, _
                        Title:="Form Protected by password", XPos:=2000, YPos:=2000)
    If strInput <> "YourPassword" Then
        Cancel = True

      [b]  DoCmd.OpenForm "YourAnotherFormName"[/b]
    End If

End Sub
this is with textbox to input password
Code:
Private Sub cmdOpenForm_Click()
    If Me.txtPassword = "YourPassword" Then
        DoCmd.OpenForm "YourFormName"
    Else
      [b]  DoCmd.OpenForm "YourAnotherFormName"[/b]
    End If
End Sub

hope you got an idea

________________________________________________________
Zameer Abdulla
Help to find Missing people
Do not cut down the tree that gives you shade.
 
Great ! Thanks for the help, I was just also wondering if there would be any way for the user to change the password without having to enter design mode once they have been authenticated ?
 
You need to store the username and password in a table.
Then using a change password form ask user to enter their username and current password.
Use DlookUp to verify the password entered is correct
Use an update SQL to update the new password to the table.

Hope this helps

________________________________________________________
Zameer Abdulla
Help to find Missing people
Do not cut down the tree that gives you shade.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top