Full Version: use vba to goto a particular Switchboard page
UtterAccess Forums > Microsoft® Access > Access Forms
JustMyAlias
is there a relatively painless way to write a command in vba
to goto a particular Switchboard page?
I am using the standard switchboard, and is too late in the game for me to change now.
I want one area to be 'restricted' - I use one of the command buttons to run though a little bit of vba code and verify the pw.
If the pw is correct, I would like for the code to direct another switchboard page to open.
TIA!
AccessJunkie
See if this area of my Switchboard FAQ page answers your question:
http://www.accessmvp.com/JConrad/accessjun...ml#specificmenu
--------------------
Jeff Conrad - Access Junkie - MVP Alumnus
SDET II - Access Test Team - Microsoft Corporation
Author - Microsoft Access 2010 Inside Out
Co-author - Microsoft Office Access 2007 Inside Out
Access 2007/2010 Info: http://www.AccessJunkie.com
----------
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.mspx
----------
JustMyAlias
i think that will probably do it - will try in a minute...
but what is this part:
Forms!Switchboard.Filter = "[ItemNumber] = 0 " _
What is the ItemNumber?
tx!
JustMyAlias
i got it - ItemNumbers from the table
but the code is not working for me...
AccessJunkie
Yes, ItemNumber is the field in the table. You'll need to use the number that corresponds to the menu you want to open.
think you'll have to provide a little more information than "not working for me."
What happens?
Do you get an error?
If so, what is the error?
Does the switchboard change?
I did you enter the ItemNumber of the menu you want to open?
Which version of Access are you using?
Etc.
--------------------
Jeff Conrad - Access Junkie - MVP Alumnus
SDET II - Access Test Team - Microsoft Corporation
Author - Microsoft Access 2010 Inside Out
Co-author - Microsoft Office Access 2007 Inside Out
Access 2007/2010 Info: http://www.AccessJunkie.com
----------
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.mspx
----------
JustMyAlias
Access 2007
It appearsthat the switchboard refreshes
but stays on the main switchboard (the next one does not open)
It is SwitchboardID- 2 that I want to open, and Ihave the ItemNumber set to 0.
AccessJunkie
Thanks for the additional information. The version number makes a big difference which you didn't provide earlier.
On Access 2007, the switchboard form uses embedded macros and temporary variables to control the items and actions, instead of VBA from previous versions. For 2007, it requires a slightly different approach to make it work with the macros driving the form.
See the attached, simplified database as a guide to understand how this works.
1. Open database and enable the code to see switchboard
2. Click second option and notice you go right to the second menu. Click back to return to main.
3. Now click the third button to open the password protected menu.
4. You get an input box prompt for the password to enter. If you leave blank, cancel, or enter wrong password, you get a message box and nothing happens.
5. Enter the text "password" (no quotes though) in the InputBox and click OK
6. Notice now you can see the menu options for the third menu which was protected. You can click back to return to main.
Things to note:
- The third switchboard button does a RunCode option. Examine the code in the one module to see how this works. You should easily be able to adapt to your needs.
- This is by no means really secure in any way; it's just an example for you to review and adapt. Knowledgable users can easily get around this.
Hope that helps,
--------------------
Jeff Conrad - Access Junkie - MVP Alumnus
SDET II - Access Test Team - Microsoft Corporation
Author - Microsoft Access 2010 Inside Out
Co-author - Microsoft Office Access 2007 Inside Out
Access 2007/2010 Info: http://www.AccessJunkie.com
----------
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.mspx
----------
JustMyAlias
t/y for the response - I am just seeing this, and will check it as soon as I can.
Osupposed I should edit my autosignature to reflect my software version too...
JustMyAlias
testing...
JustMyAlias
oh!
I think i can work with this!
thank you so much.
don't really need a lot of security - just a mild deterrent.
I will have 3 "levels" of users - the end-user (Customer), Sales, and an Admin.
The end-user will likely not have any or much Access knowledge. They only need access to one data entry form.
The Sales people only need to be able to access the Customer info and print reports - but this area will have pw to prevent the end-user from getting into it.
And the "Admin" will have access to all the tables through a series of forms - to add and edit table info - this will have a 2nd pw to prevent end-user and sales from getting in the mud...
JustMyAlias
THIS IS PERFECT - thank you very much!
One quick question:
in the code, for this part:
' Finally, make the the two label controls in the header section match the switchboard name
' Remove these if you don't have those two controls in the header
Forms!Switchboard!Label1.Caption = DLookup("ItemText", "Switchboard Items", "[SwitchboardID] = " & TempVars("SwitchboardID"))
Forms!Switchboard!Label2.Caption = DLookup("ItemText", "Switchboard Items", "[SwitchboardID] = " & TempVars("SwitchboardID"))
If I have 6 selections on the pw protected menu - I need a line of code for 1-6?
because currently I have entered just this code, and it seems to be working. Fluke?
AccessJunkie
Glad to hear the example is working for you.
o answer your question, those two lines of code make the two labels in the form header section match the name of the switchboard menu. If you open the switboard form in Design view, it "looks" like there is only one label control in the form header section. However, there are actually two label controls there positioned very close together. One has a slightly different text color to give the effect that the word is 3D. If you have trouble seeing these, select Label1 and Label2 from the Property Sheet and then it will make more sense.
Don't confuse these label controls with the label controls in the form's *Detail* section. The labels in the Detail section are completely controlled by the form's embedded macros. The captions of those are dynamically filled from the macros; not from any of the code I provided.
Does that make sense?
--------------------
Jeff Conrad - Access Junkie - MVP Alumnus
SDET II - Access Test Team - Microsoft Corporation
Author - Microsoft Access 2010 Inside Out
Co-author - Microsoft Office Access 2007 Inside Out
Access 2007/2010 Info: http://www.AccessJunkie.com
----------
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.mspx
----------
JustMyAlias
makes perfect sense!
Thanks.
Odid confuse the header labels with the Detail labels...
gain,
thank you thank you
AccessJunkie
Great, glad to help.
Good luck with your project.
-------------------
Jeff Conrad - Access Junkie - MVP Alumnus
SDET II - Access Test Team - Microsoft Corporation
Author - Microsoft Access 2010 Inside Out
Co-author - Microsoft Office Access 2007 Inside Out
Access 2007/2010 Info: http://www.AccessJunkie.com
----------
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.mspx
----------
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.