Password Protect form

C

CRC

I am trying to set a password protection for each user to log into a form.
With their login name I want it to Repaint or Copy into the Name field or
control in the form after verifying that the Name and Password matches. Can
any on Help?

I tried some of the solutions that was posted by other questioners,
Form_Current using the If Not IsNull statement.
-----------------------------------
Private Sub Form_Current()

If Not IsNull(Me.OpName) Then
MsgBox "Please login."
Me.Submit.Enabled = False
ElseIf Not IsNull(Me.PW) Then
MsgBox "Retype your password."
Me.Submit.Enabled = False
ElseIf (Me.PW = "phoenix") Then
Me.Submit.Enabled = True
End If

End Sub
-----------------------
The thing with this code it keeps running back to Please login...
Heres the one for the coomand button on_click().
------------------------------------
Private Sub Submit_Click()
On Error GoTo Submit_Click_Err

Dim Submit As CommandButton
Dim PW As String

If Me.PW = "phoenix" Then

DoCmd.Close "LoginForm6"
DoCmd.OpenForm "TS 6", acNormal, "", "", acEdit, acNormal
DoCmd.GoToRecord acForm, "TS 6", acLast
DoCmd.GoToControl "Order"

Else

MsgBox "Your Name or Password did not match." & vbLf & _
"Please check and try again. "

End If

Submit_Click_Exit:
Exit Sub

Submit_Click_Err:
MsgBox Error$
Resume Submit_Click_Exit

End Sub
 
D

Daryl S

CRC -

Don't you want to check for IsNull instead of Not IsNull?
Try this:

Private Sub Form_Current()

If IsNull(Me.OpName) Then
MsgBox "Please login."
Me.Submit.Enabled = False
ElseIf IsNull(Me.PW) Then
MsgBox "Retype your password."
Me.Submit.Enabled = False
ElseIf (Me.PW = "phoenix") Then
Me.Submit.Enabled = True
End If

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Password programming 4
Form Filter acts like it does nothing 3
Choose Form that Loads Based on Login 6
Macro to VBA 20
Resume Next versus GoTo 5
Password at Login Form 6
password program 1
Error 2001 1

Top