Disable right click for Access application (not the form)

donsi

Registered User.
Local time
Today, 15:59
Joined
Sep 1, 2016
Messages
73
I disabled the right click options and close button on the form with property setup so user doesn't close the form without completing it. Then I ran into an issue where they were just simply clicking "X" on the top of the application to close the form and relaunch the app. This was creating some issues so I disabled it. Now some users are right clicking on the application at the taskbar and clicking Close. Ahhhh:mad:

Is there a way to disable this right click just for Access application?


Ps: There is a button named "EXIT" but some just ignores it.
 
You actually don't care whether they click any button at all.

If you have a setup that uses a switchboard form, you can put an Event routine for the switchboard's Form_Unload event, for which you can offer a Cancel option. Go ahead and turn off other buttons, but the real way to fix this is to trap and prevent premature closure at an event level. Since Form_Unload can be cancelled, that will have the effect of making life tougher if they want to take that approach. Yes, the Task Manager and the End Now button will make your process exit no matter what, but you can at least up the ante.

There is also the punitive way... if they need to use the app to do their jobs, then the first time they exit in a bad way, leave something in a state that the next time they try to log in, it won't let them and will FORCE them to come to you. Or better still, check with your boss first for permission to do this and then force them to get your boss to allow them to get back in, but with a warning on how they are misusing the product.

Then, there is one last question... what is it about this group that they don't understand how screwed up they are when they don't follow the instructions? This is semi-serious. Find out WHY they want to be so frickin' obstinate. It is possible that your "Close" option isn't convenient somehow. Is it slow to exit? That might be part of the issue.
 
You actually don't care whether they click any button at all.

If you have a setup that uses a switchboard form, you can put an Event routine for the switchboard's Form_Unload event, for which you can offer a Cancel option. Go ahead and turn off other buttons, but the real way to fix this is to trap and prevent premature closure at an event level. Since Form_Unload can be cancelled, that will have the effect of making life tougher if they want to take that approach. Yes, the Task Manager and the End Now button will make your process exit no matter what, but you can at least up the ante.

There is also the punitive way... if they need to use the app to do their jobs, then the first time they exit in a bad way, leave something in a state that the next time they try to log in, it won't let them and will FORCE them to come to you. Or better still, check with your boss first for permission to do this and then force them to get your boss to allow them to get back in, but with a warning on how they are misusing the product.

Then, there is one last question... what is it about this group that they don't understand how screwed up they are when they don't follow the instructions? This is semi-serious. Find out WHY they want to be so frickin' obstinate. It is possible that your "Close" option isn't convenient somehow. Is it slow to exit? That might be part of the issue.

I like the option two better because I know it's only very few culprits, I just need to fish them out. They only have three forms to work with, but for some reason they end up selecting wrong one and start entering info, then realize that it is a wrong form. I have a "Clear" button which clears the form and undos the record. Also for safety precautions, I disabled all other buttons when form is dirty on the form except "Clear" and "Submit". Once they click Clear, all the options are available, i.e. go back to correct form, exit DB. But instead of doing that, they will close it DB and relaunch it.
 
I found this on http://www.tek-tips.com/faqs.cfm?fid=2562 and it works great to hiding everything, however it doesn't let me go back to design mode with all the menu options but throws an error #2046- "The command or action 'DesignView' isn't available now" when I run below code.

Code:
Private Sub Auto_Logo0_DblClick(Cancel As Integer)

DoCmd.RunMacro "mcrRestore"
'Enable design view
DoCmd.RunCommand acCmdDesignView
'Enable Navigation Pane & Ribbon
Call DoCmd.SelectObject(acTable, , True)
DoCmd.ShowToolbar "Ribbon", acToolbarYes
End Sub

Below lists the steps to make all this work:

1. Copy the code at the bottom of this FAQ into a module. I named mine basAccessHider, but it really doesn't matter.

2. Create a macro and call it mcrHide. The Macro has one Action line - RunCode - and put the following in the Function box:

fAccessWindow ("Minimize", False, False)

3. Create another macro and call it mcrRestore. The Macro has one Action line - RunCode - and put the following in the Function box:

fAccessWindow ("Show", False, False)

4. Now the property changes.....you have set every form in your database to PopUp....find the PopUp property for each form and set it to yes. In the OnOpen event of your startup form (if you don't have a startup form, just pick the first form you open when you open the database), put the following code:

DoCmd.RunMacro "mcrHide"

5. Finally, to allow reports to be previewed...in every report you will need to put:

In the OnOpen: DoCmd.RunMacro "mcrRestore"
In the OnClose: DoCmd.RunMacro "mcrHide"

And that's about it. Not a lot of work, but it can seem confusing.

''''
' Start Code '
''''
Code:
Private Declare Function IsWindowVisible Lib "user32" (ByVal hwnd As Long) As Long
Dim dwReturn As Long

Const SW_HIDE = 0
Const SW_SHOWNORMAL = 1
Const SW_SHOWMINIMIZED = 2
Const SW_SHOWMAXIMIZED = 3

Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, _
     ByVal nCmdShow As Long) As Long
     
Public Function fAccessWindow(Optional Procedure As String, Optional SwitchStatus As Boolean, Optional StatusCheck As Boolean) As Boolean
If Procedure = "Hide" Then
    dwReturn = ShowWindow(Application.hWndAccessApp, SW_HIDE)
End If
If Procedure = "Show" Then
    dwReturn = ShowWindow(Application.hWndAccessApp, SW_SHOWMAXIMIZED)
End If
If Procedure = "Minimize" Then
    dwReturn = ShowWindow(Application.hWndAccessApp, SW_SHOWMINIMIZED)
End If
If SwitchStatus = True Then
    If IsWindowVisible(hWndAccessApp) = 1 Then
        dwReturn = ShowWindow(Application.hWndAccessApp, SW_HIDE)
    Else
        dwReturn = ShowWindow(Application.hWndAccessApp, SW_SHOWMAXIMIZED)
    End If
End If
If StatusCheck = True Then
    If IsWindowVisible(hWndAccessApp) = 0 Then
        fAccessWindow = False
    End If
    If IsWindowVisible(hWndAccessApp) = 1 Then
        fAccessWindow = True
    End If
End If
End Function
'''
' End Code '
'''

How would I be able to get back to Normal Design view?
 
The reason you are having trouble is your operational design. For a production version of a front-end, you NEVER want people to dink around with it, so you lock it down.

BUT... you always, ALWAYS, ALWAYS keep a "design master" copy hanging around. Then when you have a fix or new feature to release, you make a copy of the design master and secure so that it becomes the new production version. Then you make that version available for download.

You can search this forum for the topic of "Design Master" and also for the "Automatically Update new Front-end".
 
Don't forget you also need to trap the keyboard shortcut keys Ctrl-F4 and Ctrl-W.

Or you can use this simple technique in this example I created:

Exit with button only

his example shows how to prevent a form from closing except by using a command button. The example is the main menu/switchboard form. Note that this technique can be easily used on any form.

There is no need to disable all the title bar control box buttons. Do not have to trap the shortcut keys to close the active window (ctrl-F4 or Ctrl-w). No need to hide the Access shell or Menu bar/Ribbon

With this simple technique the only way to exit the form is to use the command button to close the form or Task Manager to End Task on MSAccess.exe. Even trying to shut down or reboot Windows will not close it.

[BONUS] It also shows how to hide a button when the front end is compiled (mde/accde).

It is all done with a few lines of simple VBA code.
 

Users who are viewing this thread

Back
Top Bottom