Hi guys i’d like to disable close button in access main window ? is this possible ?? please help !! thanks for the answer !! Andre. ____________________________________________________________ Find what you are looking for with the Lycos Yellow Pages Lycos.com
Kevin,
The code is working perfectly, and is doing exactly what I need. I
have
trying to accomplish this for over four years. Thanks
again.
My only hesitation in implementing this change today is that it is
Friday the 13th, and I confess to experiencing some
Triscadecaphobia !
Barry
At 03:13 PM 8/13/2004, you wrote:
Kevin,
Thanks very much for the code and accompanying notes. I will
implement
this solution in the three data entry forms I am concerned about, and
let
you know the result
Kevin,
Thanks very much for the code and accompanying notes. I will implement
this solution in the three data entry forms I am concerned about, and let
you know the result
Barry
At 09:29 AM 8/13/2004, you wrote:
Barry -
In the application that I built, I NEVER wanted them to close the Access
program, by using the ‘X’ in the upper right corner. I had a dialog
form, with it’s invisibility turned on prior to opening my main
switchboard where I had this code.
Barry -=20
In the application that I built, I NEVER wanted them to close the Access
program, by using the ‘X’ in the upper right corner. I had a dialog
form, with it’s invisibility turned on prior to opening my main
switchboard where I had this code.
If you are only concerned about specific forms, you could place this
code on these forms: - Hope this Helps!
In a global module, declare the following:
'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Public fCanIClose As Boolean
'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
This is a global variable that Access will check on close of the forms
in question. On each of the forms you want to control, place the
following code:
'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Private Sub Form_Unload(Cancel As Integer)
If fCanIClose =3D False Then
=20
=20
Cancel =3D True
'You can have a message box telling why they cannot do this
'MsgBox “You cannot close using this button. You may exit the
system from the main greeting screen.”, , “My Application”
End If
End Sub
'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
The next step is to set the global variable to true, on click of your
exit button, close button, whatever:
'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Private Sub cmdExit_Click()
On Error GoTo Err_Quit
If MsgBox(“Are you sure you wish to close the application?”,
vbYesNo, “My Application”) =3D vbYes Then
'Here I set the variable to true
fCanIClose =3D -1
DoCmd.Quit
End If
Exit_Quit:
Exit Sub
=20
Err_Quit:
MsgBox Err.Number & " " & Err.Description
Resume Exit_Quit
=20
End Sub
'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Thank You=20
Kevin Albrecht=20
Business Data Analyst II=20
206.490.3861=20
kevin.f.albrecht@wamu.net=20
Hi
I use this useful code, you need to setup the module then call that from
the form
Module
Option Compare Database
Private Declare Function apiEnableMenuItem Lib “user32” Alias _
“EnableMenuItem” (ByVal hMenu As Long, ByVal wIDEnableMenuItem As Long, _
ByVal wEnable As Long) As Long
Private Declare Function apiGetSystemMenu Lib “user32” Alias _
“GetSystemMenu” (ByVal hWnd As Long, ByVal Flag As Long) _
As Long
’
’
’
Function EnableDisableControlBox(bEnable As Boolean, _
Optional ByVal lhWndTarget As Long = 0) As Long
Barry -
Yes, your assumption is correct. I will send it to you when I get in the
office tomorrow. - Thanks
Kevin,
Yes, I am interested in your code, however I have one question:
For your code to trap exiting Access, I assume it would only have
to be present in those forms where I am trying to prevent the user
from exiting Access while that form is open? (hope this
makes sense). And for clarification, the ‘Close’ box on these forms
is already disabled.
I look forward to your reply, as I have been searching for a
solution to this issue for some time.
Thanks,
Barry
At 05:09 PM 8/12/2004, you wrote:
Without an Access runtime, you cannot do this. You can however have
code on your forms to work around this. Let me know if you are
interested, as I just worked through this 6 months ago.
Without an Access runtime, you cannot do this. You can however have
code on your forms to work around this. Let me know if you are
interested, as I just worked through this 6 months ago.
I am interested in this question also, and in every response I have found on the web, the question seems to be misunderstood:
-
We already know how to disable the close box on forms. We are refering to the close box on the main Access application bar. How to you disable that?
-
It does not help to design a custom tool bar. That does not affect the close box on the main Access application bar.
An answer would be greatly appreciated.
Not sure if this is correct but…
Private Sub Form_Unload(Cancel As Integer)
If fCanIClose=false then
Cancel=true
End if
End Sub
HTH
Good thoughts, but what would the syntax look like to ‘Cancel’ a close?
Thank you
Kevin Albrecht
Business Systems Analyst
206.490.5023
Projects & Analytics
You can’t disable the main access window close button without using api
calls.
One way to simulate it is to.
- Have a Main Menu form (or similar) that is always open when your app is
running.
- In the onOpen event for the main Menu form set a global flag variable
(say fCanIClose) to false.
- In the onClose event for the main menu form check fCanIClose. If it is
false, cancel the close action. (This will prevent access from closing)
- Create a close button on Main Menu and in its onClick event, set
fCanIClose to true and then quit application.
Rod
Three things you can do,
Set the forms Close Button property to no,
or
Set the forms Control Box property to No
or
Use the Forms Unload events to control if to allow the form to close when
the close “X” is clicked
Steve.