You are here:

Using MS Access/Password Protected Button

Advertisement


Question
Hi,

this is me again and I need your help!

How can I add a password to a button, i.e. whenever someone clicked on this button he has to enter a password in order to proceed to the form which the button opens?

any help will be very much appreciated!

Thanks and Regards!
CS.

Answer
Hi CS,

If you add the following code behind the button click event the required functionality should be achieved:

Sub Button_Click()
   
   Dim strInput As String, strMsg As String

   strMsg = "Enter your password."
   strInput = InputBox(Prompt:=strMsg, _
       Title:="Form Security Check", XPos:=100, YPos:=100)

   ' The required password = "YOUR PASSWORD" case insensitive

   If UCASE(strInput) = "YOUR PASSWORD" Then
        DoCmd.OpenForm "frmYourFormname", acNormal
   Else
        MsgBox "Sorry wrong password."
   End If

End Sub

Hope this helps

Kind regards

Geoff
:-)

Using MS Access

All Answers


Answers by Expert:


Ask Experts

Volunteer


Geoff

Expertise

I specialise in database analysis and design, SQL and database queries using QBE and VBA. In my work, I use MS Access together with MS SQL Server as ETL (Extraction - Transformation - Loading) tools for migrating data between business ERP systems and data stores. My forte is building bespoke functions and applications.


See my website for example apps and downloads

Experience

I am a chartered engineer with 30 years of engineering and business experience, member of the BCS and have been working specifically in database applications, including SQL Server (v7/8/2000) for the last 9 or so years. I previously taught a course in Database Analysis and Design, but am now a freelance consultant and systems analyst.

Commercial database design and development work undertaken.

©2012 About.com, a part of The New York Times Company. All rights reserved.