How can I add Password protection on a Switchboard Item within Ac.

G

Guest

I have created a switchborad with 3 button/optioins. The first 2 open forms
in add mode. The third is a "Supervisory Options". The Superviosry
Options/button will then open a subform with more selections. I want a put
"password" connected to the third button. When selected - I want to be
prompted for a password - that I can verify. If it is correct - I will
open/display the subform. If the password is unknown or wrong - the subform
should not open. I have seen this done in prior applications, but do not
know how or where to code for it. Any help would be greatly appreciated.
 
J

Jeff Conrad

in message:
I have created a switchborad with 3 button/optioins. The first 2 open forms
in add mode. The third is a "Supervisory Options". The Superviosry
Options/button will then open a subform with more selections. I want a put
"password" connected to the third button. When selected - I want to be
prompted for a password - that I can verify. If it is correct - I will
open/display the subform. If the password is unknown or wrong - the subform
should not open. I have seen this done in prior applications, but do not
know how or where to code for it. Any help would be greatly appreciated.

I'm a little confused by your terminology. Subforms are usually not opened
by themselves per se, they exist on another form. Are you sure you do
not mean "sub-menu" in this case? You want the protected option to open
up a sub-menu on the Switchboard form that will list other options, yes/no?
Like an Administrative menu perhaps?

Here is a past post of mine on this issue which should help.
Any kind of "Developer-implemented" security/password
schemes are really not all that secure. Implementing full-
blown Access User Level Security is really the *best* way
to go if you want to have some security built into your
application. It is a difficult and challenging task to implement
the first couple of times, so it is best to thoroughly read up
on the subject before beginning and practice on "dummy"
databases. If you would like some links on the subject, post
back and I'll provide a few for you.

OK, having said the above, I also believe that there are times
and places when ULS is way too much overkill. If the data
is not ultra-sensitive and/or you have really low-tech users, a
*simple* security system can be more than sufficient. I have
done this before many times in the past.

So what you are looking for is to integrate something with the
built-in Switchboard Manager, correct? Here is a past post of
mine on this subject (modified just a bit) which should do exactly
what you are looking for. As long as you the developer fully
understand the limitations of this setup, then you may proceed.

Make a backup of your database BEFORE beginning!

1. Create a new small password form with the following properties:

-Scroll Bars No
-Record Selectors No
-Navigation Buttons No
-Dividing Lines No
-Auto Center Yes
-Pop Up Yes
-Modal Yes
-Border Style Thin
-Control Box No
-Min Max Buttons None
-Close Button No
-Shortcut Menu No

Name the form frmPassword.

Add a text box on this form called txtPassword with an Input Mask
of "Password" (without the quotations).

Add a label called lblPassword and have the caption say
something like "Please Enter Administrator Password."
Position just above the text box.

Add a command button called cmdCloseForm that simply
closes the form; nothing else in that code. Like so:

'Code Start
Private Sub cmdCloseForm_Click()
On Error GoTo ErrorPoint

DoCmd.Close acForm, "frmPassword"

ExitPoint:
Exit Sub

ErrorPoint:
' Unexpected Error
MsgBox "The following error has occurred:" _
& vbNewLine & "Error Number: " & Err.Number _
& vbNewLine & "Error Description: " & Err.Description _
, vbExclamation, "Unexpected Error"
Resume ExitPoint

End Sub
' Code End

Add another command button called cmdShowAdminArea with
a caption of "OK" or something similar and enter the following code
into the Click event for this button:

'Code Start
Private Sub cmdShowAdminArea_Click()
On Error GoTo ErrorPoint

If Me.txtPassword <> "password" Then
' Substitute with your own password between the quotes
MsgBox "Incorrect Password", vbExclamation, "Access Denied"
DoCmd.Close acForm, "frmPassword"
Else
Forms!Switchboard.Filter = "[ItemNumber] = 0 And [SwitchboardID] = 2"
Forms!Switchboard.Refresh
DoCmd.Close acForm, "frmPassword"
End If

ExitPoint:
Exit Sub

ErrorPoint:
' Unexpected Error
MsgBox "The following error has occurred:" _
& vbNewLine & "Error Number: " & Err.Number _
& vbNewLine & "Error Description: " & Err.Description _
, vbExclamation, "Unexpected Error"
Resume ExitPoint

End Sub
' Code End

This assumes that the Admin Switchboard area you want to
protect is number "2" in the Switchboard Items TABLE. Make
sure to change that number to whatever matches your table
value. This also assumes that the NAME of your switchboard
form is actually just "Switchboard." Change the code if
you have changed the name. Dress up the message box with
whatever formatting and/or messages you desire.

Use the Switchboard Manager Wizard to create the entry to
go to this Admin area. Instead of using the option that
opens up a Switchboard, make it open the frmPassword
instead. Like this:

Edit Switchboard Item:
Text: Go To Admin Area
Command: Open Form In Add Mode
Form: frmPassword

Now when the person clicks on the Switchboard option that
says "Go To Admin Area" the Password form opens up on top.
Unless they enter the correct password, the Switchboard
will not change to show the Admin menu. It would also be a
good idea to hide the Database Window from the users.
Hope that gets you going,
 
G

Guest

Jeff,
THANK YOU SO MUCH........you gave me the exact code that I needed. I
understand what you stated about security and I do appreciate it - but for
this type of application and environment - the password will work
perfectly!!! Again, thanks for the help
Eileen Freeman
Hainesport, NJ

Jeff Conrad said:
in message:
I have created a switchborad with 3 button/optioins. The first 2 open forms
in add mode. The third is a "Supervisory Options". The Superviosry
Options/button will then open a subform with more selections. I want a put
"password" connected to the third button. When selected - I want to be
prompted for a password - that I can verify. If it is correct - I will
open/display the subform. If the password is unknown or wrong - the subform
should not open. I have seen this done in prior applications, but do not
know how or where to code for it. Any help would be greatly appreciated.

I'm a little confused by your terminology. Subforms are usually not opened
by themselves per se, they exist on another form. Are you sure you do
not mean "sub-menu" in this case? You want the protected option to open
up a sub-menu on the Switchboard form that will list other options, yes/no?
Like an Administrative menu perhaps?

Here is a past post of mine on this issue which should help.
Any kind of "Developer-implemented" security/password
schemes are really not all that secure. Implementing full-
blown Access User Level Security is really the *best* way
to go if you want to have some security built into your
application. It is a difficult and challenging task to implement
the first couple of times, so it is best to thoroughly read up
on the subject before beginning and practice on "dummy"
databases. If you would like some links on the subject, post
back and I'll provide a few for you.

OK, having said the above, I also believe that there are times
and places when ULS is way too much overkill. If the data
is not ultra-sensitive and/or you have really low-tech users, a
*simple* security system can be more than sufficient. I have
done this before many times in the past.

So what you are looking for is to integrate something with the
built-in Switchboard Manager, correct? Here is a past post of
mine on this subject (modified just a bit) which should do exactly
what you are looking for. As long as you the developer fully
understand the limitations of this setup, then you may proceed.

Make a backup of your database BEFORE beginning!

1. Create a new small password form with the following properties:

-Scroll Bars No
-Record Selectors No
-Navigation Buttons No
-Dividing Lines No
-Auto Center Yes
-Pop Up Yes
-Modal Yes
-Border Style Thin
-Control Box No
-Min Max Buttons None
-Close Button No
-Shortcut Menu No

Name the form frmPassword.

Add a text box on this form called txtPassword with an Input Mask
of "Password" (without the quotations).

Add a label called lblPassword and have the caption say
something like "Please Enter Administrator Password."
Position just above the text box.

Add a command button called cmdCloseForm that simply
closes the form; nothing else in that code. Like so:

'Code Start
Private Sub cmdCloseForm_Click()
On Error GoTo ErrorPoint

DoCmd.Close acForm, "frmPassword"

ExitPoint:
Exit Sub

ErrorPoint:
' Unexpected Error
MsgBox "The following error has occurred:" _
& vbNewLine & "Error Number: " & Err.Number _
& vbNewLine & "Error Description: " & Err.Description _
, vbExclamation, "Unexpected Error"
Resume ExitPoint

End Sub
' Code End

Add another command button called cmdShowAdminArea with
a caption of "OK" or something similar and enter the following code
into the Click event for this button:

'Code Start
Private Sub cmdShowAdminArea_Click()
On Error GoTo ErrorPoint

If Me.txtPassword <> "password" Then
' Substitute with your own password between the quotes
MsgBox "Incorrect Password", vbExclamation, "Access Denied"
DoCmd.Close acForm, "frmPassword"
Else
Forms!Switchboard.Filter = "[ItemNumber] = 0 And [SwitchboardID] = 2"
Forms!Switchboard.Refresh
DoCmd.Close acForm, "frmPassword"
End If

ExitPoint:
Exit Sub

ErrorPoint:
' Unexpected Error
MsgBox "The following error has occurred:" _
& vbNewLine & "Error Number: " & Err.Number _
& vbNewLine & "Error Description: " & Err.Description _
, vbExclamation, "Unexpected Error"
Resume ExitPoint

End Sub
' Code End

This assumes that the Admin Switchboard area you want to
protect is number "2" in the Switchboard Items TABLE. Make
sure to change that number to whatever matches your table
value. This also assumes that the NAME of your switchboard
form is actually just "Switchboard." Change the code if
you have changed the name. Dress up the message box with
whatever formatting and/or messages you desire.

Use the Switchboard Manager Wizard to create the entry to
go to this Admin area. Instead of using the option that
opens up a Switchboard, make it open the frmPassword
instead. Like this:

Edit Switchboard Item:
Text: Go To Admin Area
Command: Open Form In Add Mode
Form: frmPassword

Now when the person clicks on the Switchboard option that
says "Go To Admin Area" the Password form opens up on top.
Unless they enter the correct password, the Switchboard
will not change to show the Admin menu. It would also be a
good idea to hide the Database Window from the users.
Hope that gets you going,
 
J

Jeff Conrad

in message:
Jeff,
THANK YOU SO MUCH........you gave me the exact code that I needed. I
understand what you stated about security and I do appreciate it - but for
this type of application and environment - the password will work
perfectly!!! Again, thanks for the help
Eileen Freeman
Hainesport, NJ

You're very welcome, glad I could help.
Thanks for the feedback.
 

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