password protect a form

recon0302

Registered User.
Local time
Today, 01:44
Joined
Oct 9, 2002
Messages
27
I am looking for a simple way of password protecting a form in a database. Any suggestions?
 
If you do not want to use a form and do not mind the simplicity of an input box, try this...

Code:
Private Sub bOpenFormClick_Click()
On Error GoTo Err_bOpenFormClick_Click
    
    Dim strInput As String
    Dim strMsg As String
    
    Beep
    strMsg = "These functions are used only by the special people." & vbCrLf & vbLf & "Please key the Special Form password to allow access."
    strInput = InputBox(Prompt:=strMsg, title:="Special Form Password")
    If strInput = "SpecialPassword" Then 'password is correct
        Beep
        DoCmd.OpenForm "fSpecialForm"
        DoCmd.Close acForm, Me.Name
    Else 'password is incorrect
        Beep
        MsgBox "Incorrect Password!" & vbCrLf & vbLf & "You are not allowed access to the special form.", vbCritical, "Invalid Password"
        Exit Sub
    End If
    
bEdit_Click_Exit:
    Exit Sub
    
Err_bEdit_Click:
    MsgBox Err.Number & " " & Err.Description
    Resume bEdit_Click_Exit
    
Exit_bOpenFormClick_Click:
    Exit Sub
    
Err_bOpenFormClick_Click:
    ErrorMsg Me.Name, "bOpenFormClick_Click", Err.Number, Err.Description
    Resume Exit_bOpenFormClick_Click
    
End Sub

'You can not format an input box

'HTH
 
I tried both of the above but the form opens with no change. Maybe I'm not doing something right. I open the code builder and copied the info in it and dropped it in the area "On Open"in the properties window. Any ideas or direction would be greatly appreciated. Thanx.

Marty
 
I tried both of the above but the form opens with no change. Maybe I'm not doing something right. I open the code builder and copied the info in it and dropped it in the area "On Open"in the properties window. Any ideas or direction would be greatly appreciated. Thanx.

Marty
 
To Greg and Tim

You guys are great. Took some playing with but I got it and it works too cool. I owe you big time. I enjoy playing with Access but its sometimes overwhelming (for me) with its capabilities. Thanx again.

Marty
 

Users who are viewing this thread

Back
Top Bottom