Consulting

Results 1 to 2 of 2

Thread: Password Protected userform

  1. #1
    VBAX Regular GreenDR's Avatar
    Joined
    Oct 2012
    Location
    India
    Posts
    25
    Location

    Password Protected userform

    Hi guys,


    I'm looking for a way to ask the user for a password when he clicks the close icon of the form in MS Access.
    --The form is opened automatically when database is opened.

    if the password is correct, then
    close the form
    else
    alert that password is incorrect and go back to the form.

    Thanks in advance guys!
    GreenDR

  2. #2
    VBAX Expert Dave's Avatar
    Joined
    Mar 2005
    Posts
    835
    Location
    Not sure about access but this works for XL. HTH. Dave
    [VBA]
    Private Sub UserForm_QueryClose _
    (Cancel As Integer, CloseMode As Integer)
    Dim Password As String
    If CloseMode = vbFormControlMenu Then
    Password = Application.InputBox("Enter Password")
    If Password = "Password" Then
    Cancel = False
    Else
    MsgBox "Wrong password"
    Cancel = True
    End If
    End If
    End Sub

    [/VBA]

Posting Permissions

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