Solved Switchboard - disable right-click close menu.

What I really want is similar to what I have in Reply #17 and what you have in Reply #10 - i.e.

If they right-click on the switchboard tab and click close, nothing happens b/c the DoCmd.CancelEvent catches it.

But if they click the red X on the Access Application, it should close with no message.

I just can't figure out how to do that, b/c I can't see how to set a flag from the Red X to run the switchboard unload event.

What I have is where if they close it the form re-opens, but it might take 60 seconds to start re-opening, but it's better than I started with.
I believe you can disable that x button, and then just use your own button?
 
I believe you can disable that x button, and then just use your own button?
Yes, you can and that would be an option:

It is more of an inertia thing. We've been using the X button to close Access for over 20 years. I don't want to have to tell everyone "The close button is disabled and you have to close Access using the close button on the switchboard, b/c there is a right-click menu to close the switchboard that I can't disable and the switchboard needs to stay open."
 
I think you should be testing for vbYes, not True?
Yes, exactly, I just threw the response together real fast without testing it. I respond faster than I should without verifying if my idea will work / is correct.
 
I think it is "If Confirm = True" and "If Msgbox = vbYes", but I might be mixing VBA and javascript ...
 
Not totally solved, but I'm satisfied with it ...


I ended up setting it so that if you close the switchboard, it comes back within 3 seconds, but the system still only checks every 60 seconds to see if the logout command was issued.
 
I ran into a couple of glitches, but I think I know how to fix them - but I'm open to ideas:

  • First, I have my autoexect tied to the switchboard and the database starts with progress bars for loading and checking for updates. If I close the database with the red X, on some systems I still see these, which means the hidden form is trying to re-open the switchboard, so I think I need to set the timeout to 5 or 10 seconds instead of three to prevent this. (Or disable the red X and use my own button that I can control.)
  • Second - I'd really prefer to have a "This is not recommended are you sure?" message if you close the switchboard via the right-click menu, but I don't want that if you click the red X - but I think the close and unload events fire when you click the red X so I don't think I can do that (other than disabling the red X and adding my own close button.
 
Another approach would be to have a hidden form that loads when the program is opened. It will cycle through on a timer that if it detects that the switch board form is closed, it will re-open it. I found this code online which I'm using to auto-close all forms on a database and log the user out if left idle for 30 minutes. Perhaps you should use it but in reverse. If the switch board form is closed, the hidden form will check every 15 or 30 seconds, re-open the switch board form.

learn . microsoft . com / en-us / office / vba / access / Concepts / Miscellaneous / detect-user-idle-time-or-inactivity
This is an OLD one but here is the correct CLICK THIS LINK
 
For info, you can also disable certain menu items in the navigation pane using
Code:
DoCmd.LockNavigationPane True

Set to False to restore normal functionality

For more info on ways of locking down your app, see
DARN Colin, you save my "rear" again..
 

Users who are viewing this thread

Back
Top Bottom