Form as a Switchboard

Peterson

Bob
Local time
Today, 13:31
Joined
Jul 25, 2008
Messages
28
I am using a form in access as a main switchboard for a database. The main switchboard takes me to a second switchboard form via control button and macro. I only want limited access to the second switchboard is there any way to password protect the macro fired by the first control button so only aurtherized personel will be able to access the second switchboard?:confused:
 
It is beyond my knowledge but I am using front-end and back-end database so this will enbale you to circulate different versions of front-end to different users.
 
Sure try putting this on the button that takes you to the second form. Of course you will have to give the users the password that you create.

Dim stDocName As String
Dim stLinkCriteria As String
Dim PassWord As String

stDocName = "SecondFormNameHere"

PassWord = InputBox("Enter Password")
If PassWord = "Enteryourdesiredpasswordhere" Then
' Open Form
DoCmd.OpenForm "SecondFormNameHere"
Else
MsgBox ("Sorry, You are not authorized access to this section")
End If
 
This is what I did and it dosn't work. I get the following Error Message: Invalid outside procedure.

Option Compare Database
Dim stDocName As String
Dim stLinkCriteria As String
Dim PassWord As String
stDocName = "SW 2 Macro"
PassWord = InputBox("Enter Password")
If PassWord = "Ice" Then
' Open Form
DoCmd.OpenForm "SW 2"
Else
MsgBox ("Sorry, You are not authorized access to this section")
End If
Private Sub Command5_Click()
On Error GoTo Err_Command5_Click
Dim stDocName As String
stDocName = "Macro Supervisor"
DoCmd.RunMacro stDocName
Exit_Command5_Click:
Exit Sub
Err_Command5_Click:
MsgBox Err.Description
Resume Exit_Command5_Click

End Sub
Private Sub Command6_Click()
On Error GoTo Err_Command6_Click
Dim stDocName As String
stDocName = "SW 2 Macro"
DoCmd.RunMacro stDocName
Exit_Command6_Click:
Exit Sub
Err_Command6_Click:
MsgBox Err.Description
Resume Exit_Command6_Click

End Sub
 
Last edited:
stDocName = "SW 2 Macro"
PassWord = InputBox("Enter Password")
If PassWord = "Ice" Then
' Open Form
DoCmd.OpenForm "SW 2"

Your stDocName and DoCmd.OpenForm should be the same.

If your form is SW 2 then that is what should be in both places.
Try that and let me know.
 
Same Error Message: Invalid outside procedure.

Option Compare Database
Option Compare Database
stDocName = "SW 2"
Password = InputBox("Enter Password")
If Password = "Ice" Then
' Open Form
DoCmd.OpenForm "SW 2"
Private Sub Command5_Click()
On Error GoTo Err_Command5_Click
Dim stDocName As String
stDocName = "Macro Supervisor"
DoCmd.RunMacro stDocName
Exit_Command5_Click:
Exit Sub
Err_Command5_Click:
MsgBox Err.Description
Resume Exit_Command5_Click

End Sub
Private Sub Command6_Click()
On Error GoTo Err_Command6_Click
Dim stDocName As String
stDocName = "SW 2"
DoCmd.RunMacro stDocName
Exit_Command6_Click:
Exit Sub
Err_Command6_Click:
MsgBox Err.Description
Resume Exit_Command6_Click

End Sub
Private Sub Command5_Click()
On Error GoTo Err_Command5_Click
Dim stDocName As String
stDocName = "Macro Supervisor"
DoCmd.RunMacro stDocName
Exit_Command5_Click:
Exit Sub
Err_Command5_Click:
MsgBox Err.Description
Resume Exit_Command5_Click

End Sub
Private Sub Command6_Click()
On Error GoTo Err_Command6_Click
Dim stDocName As String
stDocName = "SW 2"
DoCmd.RunMacro stDocName
Exit_Command6_Click:
Exit Sub
Err_Command6_Click:
MsgBox Err.Description
Resume Exit_Command6_Click

End Sub
 
Is "SW 2" a form? do you have a button that you click to open "SW 2"?
If you have a button to open "SW 2", then put what I gave you and only
what I gave you on the "on click" event for the button. There should be nothing else but that VB for the password prompt.
 
I have a switchboard with a button on it that should open the form sw 2. I have this on the click on line.

stDocName = "SW 2"
Password = InPutBox ("Enter Password")
If Password = "Ice" Then ' Open Form
DoCmd.Open Form "SW 2"


It gives me Error Message: Microsoft Office Access can't find Marco 'stDocName=SW 2
 
Last edited:
Dim stDocName As String
Dim stLinkCriteria As String
Dim PassWord As String

stDocName = "SW 2"

PassWord = InputBox("Enter Password")
If PassWord = "Ice" Then
' Open Form
DoCmd.OpenForm "SW 2"
Else
MsgBox ("Sorry, You are not authorized access to this section")
End If
---------------------
Make sure you from: Dim stDocName As String all the way down to End If
in the "on click" event. Looks like from what you pasted you are missing
the first 3 DIM lines.
 
OK this is what I have

Dim stDocName As String
Dim stLinkCriteria As String
Dim PassWord As String
stDocName = "SW 2"
PassWord = InputBox("Enter Password")
If PassWord = "Ice" Then
' Open Form
DoCmd.OpenForm "SW 2"
Else
MsgBox ("Sorry, You are not authorized access to this section")
End If

This is the massage I'm getting
Microsoft Office Access can't find macro Dim stDocName as string Dim stlink Criteria as string Dim Password as String
 
Try putting an underscore _ in the form name "SW_2" or rename your form
to "SW2" with no spaces.
 
How do you have your switchboard? using the built in switchboard or did you make your own using a blank form? Mine main switchboard is an actual form with buttons and labels for each button. I'm thinking that might be your problem if you are using the built in switchboard funtion in access.

Try this... create a blank form... put a button on it to open any form you want. Post that script, make the necessary changes and test it that way.
 
I made my own Switchboard useing a form. The button is a control button told to open form SW2. I did change the name of the form to SW2 and changed it on the button as you suggested. It's still not working.
 
can you zip ur DB and send to me to take a look?
 
do you know how to make a zip file? once you do, then where you reply back, just attach it there using the paperclip at the top where the toolbar is.
 
Do you have winzip? that is the best way to zip it and attach it here.
 
OK, I figured it out know to do it, but now I keep getting an error message from the web site, it has encountered an error and it will not upload. The file is only 644 KB and is a MDB file.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom