Password protection using VBA

JUDO

Registered User.
Local time
Today, 22:38
Joined
Aug 21, 2003
Messages
26
I would like to put a simple password protection on part of my database. As the database is networked I don't want to use the offical route as it could cause all kinds of problems. Has anyone got some simple code that asks for a password input before opening a form?
Thanks in advance for your assistance.
 
Last edited:
Password Protection using VBA

Judo

Have you searched the forum using "password" or "security". There are numerous examples of password protecting a database without using Access security. There is a particularly good example of a security system posted by Hayley Baxter.
 
yes already look through there not what i'm looking for.
 
This is how you can use an Input Box to password protect a command button...

Code:
    Dim strInput As String
    Dim strMsg As String
    
    Beep
    strMsg = "This form is used only by the ''Special Form'' people." & vbCrLf & vbLf & "Please key the ''Special Form'' password to allow access."
    strInput = InputBox(Prompt:=strMsg, title:="Special Password")
    If strInput = "SpecialFormPassword" Then 'password is correct
        DoCmd.OpenForm "YourSpecialFormNameHere"
        DoCmd.Close acForm, Me.Name
    Else 'password is incorrect
        MsgBox "Incorrect Password!" & vbCrLf & vbLf & "You are not allowed access to the ''Special Form''.", vbCritical, "Invalid Password"
        Exit Sub
    End If
You can not format an input box!

If you need the extra security of displaying ******** instead of the typed password
then you will have to create a form and format the text box as a password.

HTH
 
ghudson,

Couldn't that be by-passed by using the Shift key when opening the db file then looking at the design of the form? Or am I missing something?
 
Yes, getting to the code would allow a user to see the password. I only use this on db's that I have secured so the user will not be able to find/see the password within the VBA.

I also disable the shift key as I have posted my methods before: Shift key

Converting the db to MDE would also protect the code and the password.

This is just a simple way to protect a button for I only use it to keep the gremlins away when I want to use a quick and easy way to do it. This method is usually good enough for those posting the question. Creating a form with the field formatted for a password would be better. Still the db needs to be secured or else the passwords could be found.
 

Users who are viewing this thread

Back
Top Bottom