A 2010 Form Password

Dick7Access

Dick S
Local time
Today, 05:25
Joined
Jun 9, 2009
Messages
4,325
I have the following code on “On Load”. If I enter the wrong PW it gives me the, Wrong Pass Word Virginia
But if I hit ok it opens the form anyways. What am I missing?


Code:
  Private Sub Form_Load()
  Dim PassWord As String
  PassWord = InputBox("Enter You Know What Virginia")
  If PassWord = "xxx" Then
  ' Open Form
  DoCmd.OpenForm "frmBap411"
  DoCmd.Maximize
  Else
  MsgBox ("Wrong Pass Word Virginia.")
  End If
  End Sub
 
You are opening a form, asking for a password won't prevent this if there's no action to prevent it. On a wrong pasword close the form like:
Code:
  Private Sub Form_Load()
     Dim PassWord As String
     PassWord = InputBox("Enter You Know What Virginia")
     If PassWord  "xxx" Then
  '     Open Form
  [COLOR="Red"]'[/COLOR]     DoCmd.OpenForm "frmBap411" [COLOR="SeaGreen"]not required you are already opening the form[/COLOR]
        DoCmd.Maximize
     Else
        MsgBox ("Wrong Pass Word Virginia.")
[COLOR="red"]        DoCmd.Close acForm, Me.Form.Name [/COLOR][COLOR="SeaGreen"]'close the form[/COLOR]
     End If
  End Sub

As a remark, a password check like this is not case sensitive.
 
You are opening a form, asking for a password won't prevent this if there's no action to prevent it. On a wrong pasword close the form like:
Code:
  Private Sub Form_Load()
     Dim PassWord As String
     PassWord = InputBox("Enter You Know What Virginia")
     If PassWord  "xxx" Then
  '     Open Form
  [COLOR=Red]'[/COLOR]     DoCmd.OpenForm "frmBap411" [COLOR=SeaGreen]not required you are already opening the form[/COLOR]
        DoCmd.Maximize
     Else
        MsgBox ("Wrong Pass Word Virginia.")
[COLOR=red]        DoCmd.Close acForm, Me.Form.Name [/COLOR][COLOR=SeaGreen]'close the form[/COLOR]
     End If
  End Sub
As a remark, a password check like this is not case sensitive.

Works well, Thanks again!
Dick S.
 

Users who are viewing this thread

Back
Top Bottom