Password Protect a switchboard item

J

Jeff Conrad

G

Guest

Thank you very much!

Jeff Conrad said:
See this page on my site for any and all Switchboard Manager questions:

http://home.bendbroadband.com/conradsystems/accessjunkie/switchboardfaq.html

In your particular case, this specific area:

http://home.bendbroadband.com/conradsystems/accessjunkie/switchboardfaq.html#security

(Watch out for any possible line wrapping on those links)
--
Jeff Conrad
Access Junkie - MVP
http://home.bendbroadband.com/conradsystems/accessjunkie.html
http://www.access.qbuilt.com/html/articles.html

in message:
 
G

Guest

I tried exactly what you said but I am getting an error. I'm getting a
"compile error: Label not defined". It is highlighting the On Error GoTo
ErrorPoint in the code for the cmdShowAdminArea.
 
J

Jeff Conrad

If you did a simple copy/paste of the code it should be just fine.
If you kept your existing Error Handler code than you will
need to adjust the code I provided to your specifications.

For example, you would have something like
On Error GoTo <<name of your error handler here>>

If you still have problems, post all the code you have so far.
--
Jeff Conrad
Access Junkie - MVP
http://home.bendbroadband.com/conradsystems/accessjunkie.html
http://www.access.qbuilt.com/html/articles.html

in message:
 
G

Guest

Here is the code I'm using. Let me know if I did something wrong. I used the
exact code you had outlined.

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:
End Sub

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

End Sub
 
J

Jeff Conrad

in message:

Comment inline.....
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:
End Sub

The line just above should actually be Exit Sub, not End Sub.
Make the change, compile the code, and then test.
 
G

Guest

Ok it works now but I have another question. If I leave the password field
blank and click "ok" it allows me to pass through. Is there any way to
eliminate this?

Jeff Conrad said:
in message:

Comment inline.....
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:
End Sub

The line just above should actually be Exit Sub, not End Sub.
Make the change, compile the code, and then test.

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

End Sub

--
Jeff Conrad
Access Junkie - MVP
http://home.bendbroadband.com/conradsystems/accessjunkie.html
http://www.access.qbuilt.com/html/articles.html
 
J

Jeff Conrad

in message:
Ok it works now but I have another question. If I leave the password field
blank and click "ok" it allows me to pass through. Is there any way to
eliminate this?

Oops, looks like I missed a step!

Change the code to this:

'********Start of new code**********
Private Sub cmdShowAdminArea_Click()
On Error GoTo ErrorPoint

If Len(Nz(Me!txtPassword, "")) = 0 Then
MsgBox "Please enter a password before continuing." _
, vbCritical, "Missing Password"
Me.txtPassword.SetFocus
Else
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
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 of new code**********

End Sub

That should do it.
 
G

Guest

Ok thanks for all your help! I greatly appreciate it!

Jeff Conrad said:
in message:
Ok it works now but I have another question. If I leave the password field
blank and click "ok" it allows me to pass through. Is there any way to
eliminate this?

Oops, looks like I missed a step!

Change the code to this:

'********Start of new code**********
Private Sub cmdShowAdminArea_Click()
On Error GoTo ErrorPoint

If Len(Nz(Me!txtPassword, "")) = 0 Then
MsgBox "Please enter a password before continuing." _
, vbCritical, "Missing Password"
Me.txtPassword.SetFocus
Else
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
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 of new code**********

End Sub

That should do it.
--
Jeff Conrad
Access Junkie - MVP
http://home.bendbroadband.com/conradsystems/accessjunkie.html
http://www.access.qbuilt.com/html/articles.html
 
G

Guest

Actually I do have one more question...In your instructions it says that it's
set up for switchboardID 2. Can you elaborate on that? I'm a little unclear
what this means. I changed the 5th one down on my list to use this password
function. How is that one ID #2?
 
T

TC

Just for my interest, is Secret Squirrel your own posting name, or is
that a common name for all people posting through a common service of
some kind?

The reason I ask, is that I did not realize for some time, that Nomen
Nescio is not a single person; it is the name given to all people who
post through certain anonymizing services.

I'm just interested to know if Secret squirrel is simiar, or not.

TIA,
TC
 
J

Joan Wild

Secret said:
Yes I am. Is there another way to create a switchboard?

Sure, just create your own unbound form and add all the command buttons,
text boxes, combo boxes, any control you like. I find it much more flexible
than the switchboard manager.

FWIW
 

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

Similar Threads


Top