Page 1 of 3 123 LastLast
Results 1 to 15 of 34

Thread: Password (2003)

  1. #1
    5 Star Lounger
    Join Date
    May 2003
    Location
    Sheffield, Yorkshire
    Posts
    951
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Password (2003)

    I have a similar problem with passwords, as in <post#=487,248>post 487,248</post#>, but this time I have put code in the on open property of the form, to ask for a password. I want the entered password to appear as asterisks/

  2. Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

  3. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 16 Times in 16 Posts

    Re: Password (2003)

    What are you using to prompt for the password? The InputBox function?

  4. #3
    5 Star Lounger
    Join Date
    May 2003
    Location
    Sheffield, Yorkshire
    Posts
    951
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Password (2003)

    Yes, the input box

  5. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 16 Times in 16 Posts

    Re: Password (2003)

    There is no way to make InputBox mask the password with asterisks. As in <post#=487250>post 487250</post#>, the solution is
    <hr>You can create a form with a text box in which the user can enter the password. If you set the Input Mask property of the text box to PASSWORD, all characters entered by the user will be displayed as asterisks.<hr>
    You can pop up this custom form in the On Open or On Load event of your form.

  6. #5
    5 Star Lounger
    Join Date
    May 2003
    Location
    Sheffield, Yorkshire
    Posts
    951
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Password (2003)

    Thanks Hans, I'll give that a try. Thanks again.

  7. #6
    5 Star Lounger
    Join Date
    May 2003
    Location
    Sheffield, Yorkshire
    Posts
    951
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Password (2003)

    I've added a form with a password, and added a parameter in the query, but how do I set what the password should be, and how to compare it. Will I need to create a password table?

  8. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 16 Times in 16 Posts

    Re: Password (2003)

    It all depends on how secure you want things to be. If you put the correct password in a table, or in the code behind the form, users will be able to crack the password by looking at the table or code.

    By far the best way to organize security is to set up user-level security. That way, you can give different users different permissions in the database. The usernames and passwords aren't stored in the database itself, but in a secured workgroup information file (.mdw). See WendellB's tutorial The Secrets of Security; it contains a short introduction and provides lots of useful links.

  9. #8
    5 Star Lounger
    Join Date
    May 2003
    Location
    Sheffield, Yorkshire
    Posts
    951
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Password (2003)

    Not many here know how to get to the code once the database is run. We just want to prevent unauthorised people changing the data.

  10. #9
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 16 Times in 16 Posts

    Re: Password (2003)

    The attached database shows one possible way to handle passwords. If you open frmData, the password form frmPassword will be displayed first. If you enter the correct password ("secret"), you can edit the data in frmData, otherwise it will be read-only.

    There is no protection at all, so anyone can view the code to retrieve the password.

  11. #10
    5 Star Lounger
    Join Date
    May 2003
    Location
    Sheffield, Yorkshire
    Posts
    951
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Password (2003)

    That will do for what I want at the moment thanks. No one can view the code, because I use code to disable the Shift Key from being used, unless I require it. Thanks.

  12. #11
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Password (2003)

    The shift key to bypass autoexec is only one way to expose the database window. Exposing the database window is not actually required in order to view code., since code is visible in the VB editor, not in the database window.
    Charlotte

  13. #12
    5 Star Lounger
    Join Date
    May 2003
    Location
    Sheffield, Yorkshire
    Posts
    951
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Password (2003)

    Which part of the code, allows editing if the password is correct, and stops it if it is wrong. I want to stop the form from opening at all. Thanks.

  14. #13
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 16 Times in 16 Posts

    Re: Password (2003)

    The code behind the OK button on frmPassword sets the variable blnEdit to True if the password is correct. The On Open event of frmData uses this. If you don't want to open frmData, change the latter from

    Private Sub Form_Open(Cancel As Integer)
    DoCmd.OpenForm FormName:="frmPassword", WindowMode:=acDialog
    If blnEdit = True Then
    Me.RecordsetType = 0
    End If
    End Sub

    to

    Private Sub Form_Open(Cancel As Integer)
    DoCmd.OpenForm FormName:="frmPassword", WindowMode:=acDialog
    Cancel = Not blnEdit
    End Sub

  15. #14
    5 Star Lounger
    Join Date
    May 2003
    Location
    Sheffield, Yorkshire
    Posts
    951
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Password (2003)

    Where would I put a message box telling them the password was incorrect?

  16. #15
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 16 Times in 16 Posts

    Re: Password (2003)

    For example in the On Click event of the OK button on frmPassword. The following code will give the user three chances to enter the correct password.

    Private Sub cmdOK_Click()
    Static intCount As Integer
    If IsNull(Me.txtPassword) Then
    MsgBox "Please enter a password!", vbExclamation
    Me.txtPassword.SetFocus
    ElseIf Me.txtPassword = "secret" Then
    Form_frmData.blnEdit = True
    DoCmd.Close acForm, Me.Name, acSaveNo
    ElseIf intCount = 2 Then
    MsgBox "Three strikes - you're out!", vbExclamation
    Form_frmData.blnEdit = False
    DoCmd.Close acForm, Me.Name, acSaveNo
    Else
    MsgBox "Password incorrect. Please try again.", vbExclamation
    Me.txtPassword.SetFocus
    intCount = intCount + 1
    End If
    End Sub

Page 1 of 3 123 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •