form security

G

Gina Whipp

Nora White,

Something like...

If Me.txtPassword = "PutYourPasswordHere" Then
DoCmd.OpenForm "NameOfYourFormHere"
Else
MsgBox "You do not have permission to enter this area!"
DoCmd.Close
End If

....should work. Place in the On-Click of the button that opens the form.

--
Gina Whipp
2010 Microsoft MVP (Access)

http://www.regina-whipp.com/index_files/TipList.htm

When using a button to open a form, Can I put a password on this action?
What they are opening has private information, they need to know the
password to see it.

Submitted via EggHeadCafe - Software Developer Portal of Choice
Book Review: Excel 2010 - The Missing Manual [OReilly]
http://www.eggheadcafe.com/tutorial...w-excel-2010--the-missing-manual-oreilly.aspx
 
G

Gina Whipp

Tom,

In the On_Open event would be a *much* better place but the OP did say they
already use a button...

--
Gina Whipp
2010 Microsoft MVP (Access)

http://www.regina-whipp.com/index_files/TipList.htm

On Mon, 16 Aug 2010 15:29:53 -0400, "Gina Whipp"

This works, but what if in the future we can open the form using a
different method, such as the Navigation Pane, a Ribbon, etc.? I think
it's much better to write code in the Form_Open even because it will
always run regardless of how it was opened:
If g_strPassword <> "PutYourPasswordHere" then
Cancel = True 'Stop opening the form.
End If
This assumes we have previously saved the password in global variable
g_strPassword.

-Tom.
Microsoft Access MVP

Nora White,

Something like...

If Me.txtPassword = "PutYourPasswordHere" Then
DoCmd.OpenForm "NameOfYourFormHere"
Else
MsgBox "You do not have permission to enter this area!"
DoCmd.Close
End If

...should work. Place in the On-Click of the button that opens the form.
-Tom.
Microsoft Access MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top