473,322 Members | 1,496 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Hide Switchboard items

I have a switchboard built with all the items needed. I have a query that captures the current user, compares that to a table and gets the info for that user. If the user is a member of a certain group, say purchasing, I want to hide all switchboard items except for purchasing. Is there a way to do that?
Nov 21 '08 #1
5 6469
Stewart Ross
2,545 Expert Mod 2GB
Hi. If you are using the built-in switchboard manager you can't do much in the way of such customisation with it. The switchboard items are stored in the table called Switchboard in the application itself.

The Switchboard wizards that built the switchboard form for you (which is just one form, no matter how many apparently different sets of options are defined) have already generated VBA code to manage the selection of switchboard items. You would not be able to maintain the switchboard using the built-in wizards if you try to set further options for restricting the display of options under your own control.

You would need to devise a custom switchboard for yourself and show/hide items under program control. If you have a look at the code behind the built-in switchboard form you will see that this is not necessarily as straightforward as you may imagine it is.

A better option may simply be to define individual custom forms with suitable buttons and options for each group of users, opening and closing these under program control according to the user group to which the user belongs. You can use DLookup in code to lookup the value of the usergroup from your user query (the one you mention in your post that has all the details about the user and the group to which he or she belongs).

-Stewart
Nov 21 '08 #2
Thanks Stewart, I figured as much. How can I hide menu options on a custom form? Do I have to use the form "on load" event to set up if then else's for each user group (there's <10) or what?
Thanks
Emil
Nov 21 '08 #3
ADezii
8,834 Expert 8TB
  1. I'm assuming that you have a single, Access Generated Switchboard with 7 Default Buttons on it named Option1, Option2, ...Option7. If this is not the case, things get a little more complicated.
  2. The trick is not to 'Hide' the Switchboard Buttons but to 'Disable' them depending on the User.
  3. The following code, placed in the Switchboard's Open() Event will enable all 7 Buttons for the Admin User, and disable all Buttons except 5 and 7 for the User named Purchasing:
    Expand|Select|Wrap|Line Numbers
    1. Dim intCounter As Integer
    2.  
    3. 'You can't disable a Control that has the Focus, so divert the
    4. 'Focus to another Control on the Switchboard
    5. Me![cmdViewHistory].SetFocus
    6.  
    7. Select Case CurrentUser()
    8.   Case "Admin"           'Enable All Command Buttons
    9.     For intCounter = 1 To 7
    10.       Me.Controls("Option" & CStr(intCounter)).Enabled = True
    11.     Next
    12.   Case "Purchasing"      'Disable All Buttons except 5 and 7
    13.     For intCounter = 1 To 4
    14.       Me.Controls("Option" & CStr(intCounter)).Enabled = False
    15.     Next
    16.       Me.Controls("Option6").Enabled = False
    17.   Case Else
    18.     'You tell me
    19. End Select
  4. To precisely identify what Buttons were clicked on which Switchboards, I initialize Global Variables to the Caption of the Switchboard and the specific Button Clicked (Lines 4 and 5) which is defined by intBtn in the HandleClicks() Function, as in:
    Expand|Select|Wrap|Line Numbers
    1. Private Function HandleButtonClick(intBtn As Integer)
    2. 'This function is called when a button is clicked.
    3. 'intBtn indicates which button was clicked.
    4. gSwitchboardName = Me.Caption
    5. gButtonClicked = intBtn
    6.  
    7. 'Constants for the commands that can be executed.
    8. Const conCmdGotoSwitchboard = 1
    9. Const conCmdOpenFormAdd = 2
    10. Const conCmdOpenFormBrowse = 3
    11. Const conCmdOpenReport = 4
    12. Const conCmdCustomizeSwitchboard = 5
    13. Const conCmdExitApplication = 6
    14. Const conCmdRunMacro = 7
    15. Const conCmdRunCode = 8
    16.  
    17. '...yadda, yadda, yadda
  5. Let me know how you make out, and if this is what you are looking for.
P.S. - I'm making the assumption that you can handle the Lookup Code for Users/Groups yourself.
Nov 22 '08 #4
Thank you for the code. I seem to be lost in Access land. whenever I try to run the code it keeps asking me for a macro! I can't run it in step mode or anything else. Then when I try to open the form, it's giving me an error about the cmdviewhistory field. What is that? What do I change it to? The rest of the code makes sense to me except the macro part and the cmdviewhistory part.
What am I dong wrong????
Emil
Nov 22 '08 #5
ADezii
8,834 Expert 8TB
  1. Then when I try to open the form, it's giving me an error about the cmdviewhistory field. What is that?
  2. Replace cmdViewHistory with the Name of another Command Button on the Switchboard. The idea is to re-direct Focus to an Object other than a Switchboard Command Button.
  3. Replace Admin and Purchasing User Names with those appropriate to your situation.
  4. The code is for Command Buttons named Option1 thru Option7 (Default). If this does not apply to you, rename.
Nov 23 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Dejan M. | last post by:
Can you help me? I have 9 forms in the base. 2 forms are opening as single and 7 as datasheet. Thats OK, but when I used Switchboard manager, with him all of my forms are opened as single. How can...
9
by: Baz'noid | last post by:
Hi all, My computer has suddenly decided that it doesn't like the switchboard - it's quite happy to open up on other machines, meaning the database itself isn't at fault, it must be something...
5
by: Michael Keene | last post by:
I have a query that I'd like to add to my switchboard, but when I use the switchboard manager I only get the option to run a report, a macro or open a form. Is there a way to add a query without...
0
by: Earl Anderson | last post by:
I copied a Household Inventory database template in A97 (WinXP) and modified it for use in my office. Modifications consisted of changing some table names, deleting some fields, adding some fields...
1
by: jimwlee | last post by:
Hi all, I mistakenly deleted my switchboard on the Object Forms view. I recreated it again with the database utility, but the switchboard isn't showing up in the forms view. Any ideas? Thanks in...
0
by: Ace Calhoon | last post by:
Has anyone encountered this before? When a report is opened by my switchboard (i.e. either directly, or through code run by the switchboard), a crash occurs when changing print settings. So...
5
by: joebin | last post by:
I accidentally deleted the switchboard item in form list. Anyone know where I can get my switchboard back? The Switchboard Items in table list is still there. I can also view all the switchboard...
6
by: keri | last post by:
Please help, i'm baffled. I have opened my db and recieved an error on this code which starts the switchboard. As i didn't write this code i'm baffled, and I don't think I have made any changes...
3
by: allj | last post by:
I want users to be able to name the switchboard. I added a new field in the switchboard items table called name and changed the labels to txtboxs with a record source to name. If this isnull a form...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.