apply a Switchboard security

G

Guest

I have a Switchboard that was created by Access Switchboard utility.
Everything works great. What I have been told now is that one of the buttons
I created needs to have a security measure placed on it so only management
can click on the button and move on to the next Switchboard. How can I do
this or is there a way to apply security to one button on a Switchboard.
This user and pass can be hard coded
 
J

Jeff Conrad

I have a Switchboard that was created by Access Switchboard utility.
Everything works great. What I have been told now is that one of the buttons
I created needs to have a security measure placed on it so only management
can click on the button and move on to the next Switchboard. How can I do
this or is there a way to apply security to one button on a Switchboard.
This user and pass can be hard coded

Hi Ron,

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

Hi Jeff,
The users of this Access database are generally low tech users. They
have very little to no knowledge of Access. The one otyher person that does
is leaving my office for a job transfer, but if that falls through he is the
designated back-up person for Access repair or changes to databases. This
therefore does not appear to be an issue. If you want to post those links
that would help me read up on things more. I will give your solution a try,
it looks like it will work fine for what we need. Thanks

Jeff Conrad said:
I have a Switchboard that was created by Access Switchboard utility.
Everything works great. What I have been told now is that one of the buttons
I created needs to have a security measure placed on it so only management
can click on the button and move on to the next Switchboard. How can I do
this or is there a way to apply security to one button on a Switchboard.
This user and pass can be hard coded

Hi Ron,

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

Hi Ron,

Sounds like the instructions I gave should work just fine in your
case. When you are ready to move up to Access User Level
Security I would recommend ALL of the following reading material.
ULS is a difficult concept to grasp the first couple of times so
it best to practice on dummy databases first.

Access User-Level Security:

Security FAQ (the Security Bible):
http://support.microsoft.com/?kbid=207793

Jack Macdonald's Security Document:
http://www.geocities.com/jacksonmacd/AJMAccessSecurity.pdf

Lynn Trapp's Ten Security Steps:
http://www.ltcomputerdesigns.com/Security.htm

Joan Wild's Tips:
http://www.jmwild.com/security02.htm

The Security Whitepaper is also worth reading:
http://support.microsoft.com/?id=148555

Keith Wilby's Instructions (See step-by-step link)
http://www.keithwilby.com/

Other Good Information:
http://www.access-experts.com/default.aspx?selection=TutorialSecurity&sm=18

Other Microsoft KB articles of interest:

Description of how to help protect a Access 2000 database:
http://support.microsoft.com/?id=254372

Description of the role of workgroup information files in Access security:
ACC97: http://support.microsoft.com/?id=303941
ACC2000: http://support.microsoft.com/?id=305541
ACC2002/2003: http://support.microsoft.com/?id=305542

--
Jeff Conrad
Access Junkie
Bend, Oregon

Hi Jeff,
The users of this Access database are generally low tech users. They
have very little to no knowledge of Access. The one otyher person that does
is leaving my office for a job transfer, but if that falls through he is the
designated back-up person for Access repair or changes to databases. This
therefore does not appear to be an issue. If you want to post those links
that would help me read up on things more. I will give your solution a try,
it looks like it will work fine for what we need. Thanks

Jeff Conrad said:
I have a Switchboard that was created by Access Switchboard utility.
Everything works great. What I have been told now is that one of the buttons
I created needs to have a security measure placed on it so only management
can click on the button and move on to the next Switchboard. How can I do
this or is there a way to apply security to one button on a Switchboard.
This user and pass can be hard coded

Hi Ron,

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

Hi Jeff,

i had did what you have listed and it work great!!!
but is there any way to make it case-sensitive??? like my password: "admin",
irregardless whether it is caps lock or not, i will still be able to open the
switchboard... which i don't really like about it...
perhaps i'm asking a rather stupid question... but i really new to codes...

Thanks in advance
Green

Jeff Conrad said:
Hi Ron,

Sounds like the instructions I gave should work just fine in your
case. When you are ready to move up to Access User Level
Security I would recommend ALL of the following reading material.
ULS is a difficult concept to grasp the first couple of times so
it best to practice on dummy databases first.

Access User-Level Security:

Security FAQ (the Security Bible):
http://support.microsoft.com/?kbid=207793

Jack Macdonald's Security Document:
http://www.geocities.com/jacksonmacd/AJMAccessSecurity.pdf

Lynn Trapp's Ten Security Steps:
http://www.ltcomputerdesigns.com/Security.htm

Joan Wild's Tips:
http://www.jmwild.com/security02.htm

The Security Whitepaper is also worth reading:
http://support.microsoft.com/?id=148555

Keith Wilby's Instructions (See step-by-step link)
http://www.keithwilby.com/

Other Good Information:
http://www.access-experts.com/default.aspx?selection=TutorialSecurity&sm=18

Other Microsoft KB articles of interest:

Description of how to help protect a Access 2000 database:
http://support.microsoft.com/?id=254372

Description of the role of workgroup information files in Access security:
ACC97: http://support.microsoft.com/?id=303941
ACC2000: http://support.microsoft.com/?id=305541
ACC2002/2003: http://support.microsoft.com/?id=305542

--
Jeff Conrad
Access Junkie
Bend, Oregon

Hi Jeff,
The users of this Access database are generally low tech users. They
have very little to no knowledge of Access. The one otyher person that does
is leaving my office for a job transfer, but if that falls through he is the
designated back-up person for Access repair or changes to databases. This
therefore does not appear to be an issue. If you want to post those links
that would help me read up on things more. I will give your solution a try,
it looks like it will work fine for what we need. Thanks

Jeff Conrad said:
I have a Switchboard that was created by Access Switchboard utility.
Everything works great. What I have been told now is that one of the buttons
I created needs to have a security measure placed on it so only management
can click on the button and move on to the next Switchboard. How can I do
this or is there a way to apply security to one button on a Switchboard.
This user and pass can be hard coded

Hi Ron,

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:
Hi Jeff,

i had did what you have listed and it work great!!!
but is there any way to make it case-sensitive??? like my password: "admin",
irregardless whether it is caps lock or not, i will still be able to open the
switchboard... which i don't really like about it...
perhaps i'm asking a rather stupid question... but i really new to codes...

Hi Green,

My apologies for not noticing this message earlier!

Generally Access is not case sensitive, but your goal is certainly achievable.
I'm assuming you followed all of my previous instructions to the letter.

1. Make a backup of your database

2. Copy and paste this code *over* your existing code behind the command
button called cmdShowAdminArea:

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

Dim strPassword As String
Dim strEnteredPassword As String
Dim intI As Integer
Dim blnOk As Boolean

strPassword = "password"
' Set our Boolean Variable to True as default
blnOk = True

If Len(Nz(Me!txtPassword, "")) = 0 Then
' Password field blank
MsgBox "Please enter the administrative password " _
& "before continuing.", vbExclamation, "Missing Password"
' Set the focus to the text box as a visual reminder
Me.txtPassword.SetFocus
Else
' Password entered so remember it
strEnteredPassword = Me.txtPassword

' Check to see if the lengths are the same
If Len(strPassword) <> Len(strEnteredPassword) Then
' Supplied password is not the same length
MsgBox "The password you supplied is incorrect." _
& vbNewLine & "Please see the Database Administrator " _
& "for access to these functions.", vbExclamation _
, "Access Denied"
' Close the form
DoCmd.Close acForm, "frmPassword"
Else
' Now do a case-sensitive comparison
For intI = 1 To Len(strPassword)
If Asc(Mid$(strPassword, intI, 1)) <> _
Asc(Mid$(strEnteredPassword, intI, 1)) Then
' The two passwords are not the same case-wise
MsgBox "The password you supplied is incorrect." _
& vbNewLine & "Please see the Database Administrator " _
& "for access to these functions.", vbExclamation _
, "Access Denied"
' Set the boolean to false now
blnOk = False
' Close the form
DoCmd.Close acForm, "frmPassword"
Exit For
End If
Next
' Now to test our boolean to see if it is still Ok to proceed
If blnOk = True Then
' All set, close this form and open the Admin menu
Forms!Switchboard.Filter = "[ItemNumber] = 0 And " _
& "[SwitchboardID] = 2"
Forms!Switchboard.Refresh
DoCmd.Close acForm, "frmPassword"
End If
End If
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**********************

3. Make sure you enter whatever password you want to use in the
appropriate place (where it says strPassword = "password")

4. 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.

5. Compile the code, save and close the form.

Everything should be OK.

Hope that helps,
--
Jeff Conrad
Access Junkie
Bend, Oregon

Jeff Conrad said:
Hi Ron,

Sounds like the instructions I gave should work just fine in your
case. When you are ready to move up to Access User Level
Security I would recommend ALL of the following reading material.
ULS is a difficult concept to grasp the first couple of times so
it best to practice on dummy databases first.

Access User-Level Security:

Security FAQ (the Security Bible):
http://support.microsoft.com/?kbid=207793

Jack Macdonald's Security Document:
http://www.geocities.com/jacksonmacd/AJMAccessSecurity.pdf

Lynn Trapp's Ten Security Steps:
http://www.ltcomputerdesigns.com/Security.htm

Joan Wild's Tips:
http://www.jmwild.com/security02.htm

The Security Whitepaper is also worth reading:
http://support.microsoft.com/?id=148555

Keith Wilby's Instructions (See step-by-step link)
http://www.keithwilby.com/

Other Good Information:
http://www.access-experts.com/default.aspx?selection=TutorialSecurity&sm=18

Other Microsoft KB articles of interest:

Description of how to help protect a Access 2000 database:
http://support.microsoft.com/?id=254372

Description of the role of workgroup information files in Access security:
ACC97: http://support.microsoft.com/?id=303941
ACC2000: http://support.microsoft.com/?id=305541
ACC2002/2003: http://support.microsoft.com/?id=305542

--
Jeff Conrad
Access Junkie
Bend, Oregon

Hi Jeff,
The users of this Access database are generally low tech users. They
have very little to no knowledge of Access. The one otyher person that does
is leaving my office for a job transfer, but if that falls through he is the
designated back-up person for Access repair or changes to databases. This
therefore does not appear to be an issue. If you want to post those links
that would help me read up on things more. I will give your solution a try,
it looks like it will work fine for what we need. Thanks

:


I have a Switchboard that was created by Access Switchboard utility.
Everything works great. What I have been told now is that one of the buttons
I created needs to have a security measure placed on it so only management
can click on the button and move on to the next Switchboard. How can I do
this or is there a way to apply security to one button on a Switchboard.
This user and pass can be hard coded

Hi Ron,

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

hi Jeff,

thanks for your help it works great!
but actually i had included a user name to your previous code and it look
like this:

Private Sub cmdShowAdminArea_Click()
On Error GoTo ErrorPoint

If (Me.txtUser = "admin" And Me.txtPassword = "admin") Then
' Substitute with your own user and password between the quotes
Forms!Switchboard.Filter = "[ItemNumber] = 0 And [SwitchboardID] = 12"
Forms!Switchboard.Refresh
DoCmd.Close acForm, "frmPassword"
Else
If (Me.txtUser = "qiurong" And Me.txtPassword = "qiurong") Then
' Substitute with your own user and password between the quotes
Forms!Switchboard.Filter = "[ItemNumber] = 0 And [SwitchboardID] = 12"
Forms!Switchboard.Refresh
DoCmd.Close acForm, "frmPassword"
Else
MsgBox "Incorrect Password", vbExclamation, "Access Denied"
DoCmd.Close acForm, "frmPassword"
End If
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


now with your new code, i'm wondering how am i suppose to add in the user
name???
is there a way for it???

thanks in advance
Green

Jeff Conrad said:
in message:
Hi Jeff,

i had did what you have listed and it work great!!!
but is there any way to make it case-sensitive??? like my password: "admin",
irregardless whether it is caps lock or not, i will still be able to open the
switchboard... which i don't really like about it...
perhaps i'm asking a rather stupid question... but i really new to codes...

Hi Green,

My apologies for not noticing this message earlier!

Generally Access is not case sensitive, but your goal is certainly achievable.
I'm assuming you followed all of my previous instructions to the letter.

1. Make a backup of your database

2. Copy and paste this code *over* your existing code behind the command
button called cmdShowAdminArea:

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

Dim strPassword As String
Dim strEnteredPassword As String
Dim intI As Integer
Dim blnOk As Boolean

strPassword = "password"
' Set our Boolean Variable to True as default
blnOk = True

If Len(Nz(Me!txtPassword, "")) = 0 Then
' Password field blank
MsgBox "Please enter the administrative password " _
& "before continuing.", vbExclamation, "Missing Password"
' Set the focus to the text box as a visual reminder
Me.txtPassword.SetFocus
Else
' Password entered so remember it
strEnteredPassword = Me.txtPassword

' Check to see if the lengths are the same
If Len(strPassword) <> Len(strEnteredPassword) Then
' Supplied password is not the same length
MsgBox "The password you supplied is incorrect." _
& vbNewLine & "Please see the Database Administrator " _
& "for access to these functions.", vbExclamation _
, "Access Denied"
' Close the form
DoCmd.Close acForm, "frmPassword"
Else
' Now do a case-sensitive comparison
For intI = 1 To Len(strPassword)
If Asc(Mid$(strPassword, intI, 1)) <> _
Asc(Mid$(strEnteredPassword, intI, 1)) Then
' The two passwords are not the same case-wise
MsgBox "The password you supplied is incorrect." _
& vbNewLine & "Please see the Database Administrator " _
& "for access to these functions.", vbExclamation _
, "Access Denied"
' Set the boolean to false now
blnOk = False
' Close the form
DoCmd.Close acForm, "frmPassword"
Exit For
End If
Next
' Now to test our boolean to see if it is still Ok to proceed
If blnOk = True Then
' All set, close this form and open the Admin menu
Forms!Switchboard.Filter = "[ItemNumber] = 0 And " _
& "[SwitchboardID] = 2"
Forms!Switchboard.Refresh
DoCmd.Close acForm, "frmPassword"
End If
End If
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**********************

3. Make sure you enter whatever password you want to use in the
appropriate place (where it says strPassword = "password")

4. 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.

5. Compile the code, save and close the form.

Everything should be OK.

Hope that helps,
--
Jeff Conrad
Access Junkie
Bend, Oregon

Jeff Conrad said:
Hi Ron,

Sounds like the instructions I gave should work just fine in your
case. When you are ready to move up to Access User Level
Security I would recommend ALL of the following reading material.
ULS is a difficult concept to grasp the first couple of times so
it best to practice on dummy databases first.

Access User-Level Security:

Security FAQ (the Security Bible):
http://support.microsoft.com/?kbid=207793

Jack Macdonald's Security Document:
http://www.geocities.com/jacksonmacd/AJMAccessSecurity.pdf

Lynn Trapp's Ten Security Steps:
http://www.ltcomputerdesigns.com/Security.htm

Joan Wild's Tips:
http://www.jmwild.com/security02.htm

The Security Whitepaper is also worth reading:
http://support.microsoft.com/?id=148555

Keith Wilby's Instructions (See step-by-step link)
http://www.keithwilby.com/

Other Good Information:
http://www.access-experts.com/default.aspx?selection=TutorialSecurity&sm=18

Other Microsoft KB articles of interest:

Description of how to help protect a Access 2000 database:
http://support.microsoft.com/?id=254372

Description of the role of workgroup information files in Access security:
ACC97: http://support.microsoft.com/?id=303941
ACC2000: http://support.microsoft.com/?id=305541
ACC2002/2003: http://support.microsoft.com/?id=305542

--
Jeff Conrad
Access Junkie
Bend, Oregon


Hi Jeff,
The users of this Access database are generally low tech users. They
have very little to no knowledge of Access. The one otyher person that does
is leaving my office for a job transfer, but if that falls through he is the
designated back-up person for Access repair or changes to databases. This
therefore does not appear to be an issue. If you want to post those links
that would help me read up on things more. I will give your solution a try,
it looks like it will work fine for what we need. Thanks

:


I have a Switchboard that was created by Access Switchboard utility.
Everything works great. What I have been told now is that one of the buttons
I created needs to have a security measure placed on it so only management
can click on the button and move on to the next Switchboard. How can I do
this or is there a way to apply security to one button on a Switchboard.
This user and pass can be hard coded

Hi Ron,

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
 
J

Jeff Conrad

in message:
Hi Green,
thanks for your help it works great!

That's good.
but actually i had included a user name to your previous code and it look
like this:

Yes, that changes things. Revised code below....
Private Sub cmdShowAdminArea_Click()
On Error GoTo ErrorPoint

If (Me.txtUser = "admin" And Me.txtPassword = "admin") Then
' Substitute with your own user and password between the quotes
Forms!Switchboard.Filter = "[ItemNumber] = 0 And [SwitchboardID] = 12"
Forms!Switchboard.Refresh
DoCmd.Close acForm, "frmPassword"
Else
If (Me.txtUser = "qiurong" And Me.txtPassword = "qiurong") Then
' Substitute with your own user and password between the quotes
Forms!Switchboard.Filter = "[ItemNumber] = 0 And [SwitchboardID] = 12"
Forms!Switchboard.Refresh
DoCmd.Close acForm, "frmPassword"
Else
MsgBox "Incorrect Password", vbExclamation, "Access Denied"
DoCmd.Close acForm, "frmPassword"
End If
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


now with your new code, i'm wondering how am i suppose to add in the user
name???
is there a way for it???

Replace the code I provided before with this.
(I know this is not the "prettiest" code, but it works)

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

Dim strUser As String
Dim strEnteredUser As String
Dim strPassword As String
Dim strEnteredPassword As String
Dim intI As Integer
Dim blnOk As Boolean

strUser = "admin"
strPassword = "password"
' Set our Boolean Variable to True as default
blnOk = True

If Len(Nz(Me!txtUser, "")) = 0 Then
' User Name field blank
MsgBox "Please enter a User Name " _
& "before continuing.", vbExclamation, "Missing User Name"
' Set the focus to the text box as a visual reminder
Me.txtUser.SetFocus
GoTo ExitPoint
End If

If Len(Nz(Me!txtPassword, "")) = 0 Then
' Password field blank
MsgBox "Please enter a password " _
& "before continuing.", vbExclamation, "Missing Password"
' Set the focus to the text box as a visual reminder
Me.txtPassword.SetFocus
GoTo ExitPoint
End If

' User Name entered so remember it
strEnteredUser = Me.txtUser
' Password entered so remember it
strEnteredPassword = Me.txtPassword

' Check to see if the lengths are the same for User Name
If Len(strUser) <> Len(strEnteredUser) Then
' Supplied User Name is not the same length
MsgBox "The User Name/Password you supplied is incorrect." _
& vbNewLine & "Please see the Database Administrator " _
& "for access to these functions.", vbExclamation _
, "Access Denied"
' Close the form
DoCmd.Close acForm, "frmPassword"
GoTo ExitPoint
End If

' Check to see if the lengths are the same for password
If Len(strPassword) <> Len(strEnteredPassword) Then
' Supplied password is not the same length
MsgBox "The User Name/Password you supplied is incorrect." _
& vbNewLine & "Please see the Database Administrator " _
& "for access to these functions.", vbExclamation _
, "Access Denied"
' Close the form
DoCmd.Close acForm, "frmPassword"
GoTo ExitPoint
End If

' Now do a case-sensitive comparison on User Name
For intI = 1 To Len(strUser)
If Asc(Mid$(strUser, intI, 1)) <> _
Asc(Mid$(strEnteredUser, intI, 1)) Then
' The two user names are not the same case-wise
MsgBox "The User Name/Password you supplied is incorrect." _
& vbNewLine & "Please see the Database Administrator " _
& "for access to these functions.", vbExclamation _
, "Access Denied"
' Set the boolean to false now
blnOk = False
' Close the form
DoCmd.Close acForm, "frmPassword"
Exit For
End If
Next

' Now do a case-sensitive comparison on password
For intI = 1 To Len(strPassword)
If Asc(Mid$(strPassword, intI, 1)) <> _
Asc(Mid$(strEnteredPassword, intI, 1)) Then
' The two passwords are not the same case-wise
MsgBox "The User Name/Password you supplied is incorrect." _
& vbNewLine & "Please see the Database Administrator " _
& "for access to these functions.", vbExclamation _
, "Access Denied"
' Set the boolean to false now
blnOk = False
' Close the form
DoCmd.Close acForm, "frmPassword"
Exit For
End If
Next

' Now to test our boolean to see if it is still Ok to proceed
If blnOk = True Then
' All set, close this form and open the Admin menu
Forms!Switchboard.Filter = "[ItemNumber] = 0 And " _
& "[SwitchboardID] = 12"
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********************

Adjust for the correct user name/password you wish to use.

I must point out at this point that you may seriously want to consider
implementing full blown Access User Level Security (ULS). As
you can see, the code gets more complex, especially if you want
to have multiple User Name/Password combinations that will pass
the test. ULS gives you much tighter security than anything we
can "make up" as a developer. It is, however, a difficult concept
to grasp the first few times. If you wish to pursue this option, read
all of the ULS information I have accumulated here and practice
on dummy databases until you really have a complete understanding.

http://www.ltcomputerdesigns.com/JCReferences.html#Security

Hope that helps,
 
G

Guest

thanks a lot Jeff... will heed your advice ;)

Jeff Conrad said:
in message:
Hi Green,
thanks for your help it works great!

That's good.
but actually i had included a user name to your previous code and it look
like this:

Yes, that changes things. Revised code below....
Private Sub cmdShowAdminArea_Click()
On Error GoTo ErrorPoint

If (Me.txtUser = "admin" And Me.txtPassword = "admin") Then
' Substitute with your own user and password between the quotes
Forms!Switchboard.Filter = "[ItemNumber] = 0 And [SwitchboardID] = 12"
Forms!Switchboard.Refresh
DoCmd.Close acForm, "frmPassword"
Else
If (Me.txtUser = "qiurong" And Me.txtPassword = "qiurong") Then
' Substitute with your own user and password between the quotes
Forms!Switchboard.Filter = "[ItemNumber] = 0 And [SwitchboardID] = 12"
Forms!Switchboard.Refresh
DoCmd.Close acForm, "frmPassword"
Else
MsgBox "Incorrect Password", vbExclamation, "Access Denied"
DoCmd.Close acForm, "frmPassword"
End If
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


now with your new code, i'm wondering how am i suppose to add in the user
name???
is there a way for it???

Replace the code I provided before with this.
(I know this is not the "prettiest" code, but it works)

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

Dim strUser As String
Dim strEnteredUser As String
Dim strPassword As String
Dim strEnteredPassword As String
Dim intI As Integer
Dim blnOk As Boolean

strUser = "admin"
strPassword = "password"
' Set our Boolean Variable to True as default
blnOk = True

If Len(Nz(Me!txtUser, "")) = 0 Then
' User Name field blank
MsgBox "Please enter a User Name " _
& "before continuing.", vbExclamation, "Missing User Name"
' Set the focus to the text box as a visual reminder
Me.txtUser.SetFocus
GoTo ExitPoint
End If

If Len(Nz(Me!txtPassword, "")) = 0 Then
' Password field blank
MsgBox "Please enter a password " _
& "before continuing.", vbExclamation, "Missing Password"
' Set the focus to the text box as a visual reminder
Me.txtPassword.SetFocus
GoTo ExitPoint
End If

' User Name entered so remember it
strEnteredUser = Me.txtUser
' Password entered so remember it
strEnteredPassword = Me.txtPassword

' Check to see if the lengths are the same for User Name
If Len(strUser) <> Len(strEnteredUser) Then
' Supplied User Name is not the same length
MsgBox "The User Name/Password you supplied is incorrect." _
& vbNewLine & "Please see the Database Administrator " _
& "for access to these functions.", vbExclamation _
, "Access Denied"
' Close the form
DoCmd.Close acForm, "frmPassword"
GoTo ExitPoint
End If

' Check to see if the lengths are the same for password
If Len(strPassword) <> Len(strEnteredPassword) Then
' Supplied password is not the same length
MsgBox "The User Name/Password you supplied is incorrect." _
& vbNewLine & "Please see the Database Administrator " _
& "for access to these functions.", vbExclamation _
, "Access Denied"
' Close the form
DoCmd.Close acForm, "frmPassword"
GoTo ExitPoint
End If

' Now do a case-sensitive comparison on User Name
For intI = 1 To Len(strUser)
If Asc(Mid$(strUser, intI, 1)) <> _
Asc(Mid$(strEnteredUser, intI, 1)) Then
' The two user names are not the same case-wise
MsgBox "The User Name/Password you supplied is incorrect." _
& vbNewLine & "Please see the Database Administrator " _
& "for access to these functions.", vbExclamation _
, "Access Denied"
' Set the boolean to false now
blnOk = False
' Close the form
DoCmd.Close acForm, "frmPassword"
Exit For
End If
Next

' Now do a case-sensitive comparison on password
For intI = 1 To Len(strPassword)
If Asc(Mid$(strPassword, intI, 1)) <> _
Asc(Mid$(strEnteredPassword, intI, 1)) Then
' The two passwords are not the same case-wise
MsgBox "The User Name/Password you supplied is incorrect." _
& vbNewLine & "Please see the Database Administrator " _
& "for access to these functions.", vbExclamation _
, "Access Denied"
' Set the boolean to false now
blnOk = False
' Close the form
DoCmd.Close acForm, "frmPassword"
Exit For
End If
Next

' Now to test our boolean to see if it is still Ok to proceed
If blnOk = True Then
' All set, close this form and open the Admin menu
Forms!Switchboard.Filter = "[ItemNumber] = 0 And " _
& "[SwitchboardID] = 12"
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********************

Adjust for the correct user name/password you wish to use.

I must point out at this point that you may seriously want to consider
implementing full blown Access User Level Security (ULS). As
you can see, the code gets more complex, especially if you want
to have multiple User Name/Password combinations that will pass
the test. ULS gives you much tighter security than anything we
can "make up" as a developer. It is, however, a difficult concept
to grasp the first few times. If you wish to pursue this option, read
all of the ULS information I have accumulated here and practice
on dummy databases until you really have a complete understanding.

http://www.ltcomputerdesigns.com/JCReferences.html#Security

Hope that helps,
 

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