We help IT Professionals succeed at work.

How prevent user from openein a form from a main menu if the form they are trying to open has a tag of "Secure"

SteveL13 asked
Last Modified: 2015-08-11
I have a main menu form.  On that main menu form are several command buttons that have a tag of "Secure".  If the user clicks on one of the buttons that is set to open a "Secure" form, I want a password form to open and have the user enter a password.  If the password equals DLookup("[dbPassword]", "tblSetup") then let them proceed.  

If the password they enter does not equal the DLookup, present a message form and Do NOT let them in.

How can I do this from the onclick event of the form?  Or if it can't be done this way, how?

Watch Question

MIS Liason
Most Valuable Expert 2012
This one is on us!
(Get your first solution completely free - no credit card required)
Jeffrey CoachmanMIS Liason
Most Valuable Expert 2012

Note that in your "one record password table", ...you need to have a rock-solid way to prevent more that one record from ever being entered.

But this can get complicated depending on what you need, ...so this might be better dealt with in a separate, new question.

Scott McDaniel (EE MVE )Infotrakker Software
Most Valuable Expert 2012
Top Expert 2014

What's the point of using the Tag property of the control? If you want to ask the user to enter a password to open a form, use Jeff's suggestion, or do the same thing in the OnClick event of any button where a password is needed. Same concepts apply, but instead of running Jeff's code in the Open event of a Form, you run it in the Click event of the button.


Very simple and straight forward.  Thanks.
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.