Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2003

    Unanswered: Password protect a button

    Can someone point me in the right direction of how to protect a button using a password please



  2. #2
    Join Date
    Nov 2003
    Sussex, England
    I'm not sure I'm on the right track here, but could you disable the button for certain users, and use the onLoad event to check the user name and enable the button if the right user logs in.

    Another idea might be to have a form which opens before the one with the button. Gave the user type a password in there, click a button to open the second form, and if the pasword is right enable the button.

    Otherwise in the onClick event bring up a dialogue box (or a dialogue form), and have the user enter the passsword there, if it's wrong cexit the sub, otherwise go right ahead....

  3. #3
    Join Date
    Aug 2002
    Northampton, England
    Here is some code that will do the trick. Can't take credit for it though, found it on another web site.

    Private Sub PasswordProtect_Click()
    Dim strInput As String
    Dim strMsg As String

    strMsg = "This form is used only by the ''Special Form'' people." & vbCrLf & vbLf & "Please key the ''Special Form'' password to allow access."
    strInput = InputBox(Prompt:=strMsg, title:="Special Password")

    If strInput = "YourFormName" Then 'password is correct
    DoCmd.OpenForm "frmInputMask"
    DoCmd.Close acForm, Me.Name
    Else 'password is incorrect
    MsgBox "Incorrect Password!" & vbCrLf & vbLf & "You are not allowed access to the ''Special Form''.", vbCritical, "Invalid Password"
    Exit Sub
    End If
    End Sub


Posting Permissions

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