Password Protected Form

mugman17

Registered User.
Local time
Today, 22:20
Joined
Nov 17, 2000
Messages
110
I have been told to password protect a form. I have used a seperate form called frmPassword. Everything is working fine, you can get to the form by entering the proper password. My question is, is there a way of stopping them from just closing the switchboard and accessing the protected form? Is there a way of saying if the form was not opened by frmPassword, it does not get opened?
 
What kind of switchboard do you use?
The first precaution would seem to be not to let users any opportunity to close the switchboard and open a form by themselves! (modal form with no close box)
As to detecting from where a form was opened, you could use the OpenArgs property of your forms:

From the swithcboard: Docmd.OpenForm "",,,,,,"Switchboard"
From the OnOpen event of your forms: If Me.OpenArgs <> "Switchboard" Then...

Hope this helps
 
Last edited:
I normally use this from a command button to protect a form. I suggest that you use it in the forms OnOpen event to prevent unauthorized entry.

Code:
    Dim strInput As String
    Dim strMsg As String
        
    Beep
    strMsg = "This form is only used by the special department." & vbCrLf & vbLf & "Please key the special password to allow access."
    strInput = InputBox(Prompt:=strMsg, title:="Inventory Audit Password")
    If strInput = "YourSpecialPasswordHere" Then 'password is correct
        Beep
        DoCmd.OpenForm "fSpecialForm"
        DoCmd.Close acForm, Me.Name
    Else 'password is incorrect
        Beep
        DoCmd.Close acForm, "fSpecialForm"
        MsgBox "Incorrect Password!" & vbCrLf & vbLf & "You are not allowed access to the special form.", vbCritical, "Invalid Password"
        Exit Sub
    End If

HTH
 
dear mugman,
could you please let me know how did you made that form ( frmPassword) protected by password?
thank you
 

Users who are viewing this thread

Back
Top Bottom