473,569 Members | 2,984 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Close Button Problem

I have a simple app that I created for our Real Estate office using Access 2000
and it is working fine except for on thing. I need to keep the close button
hidden from the users. No problem accomplishing this it in forms using the
forms properties. However the close button for Access program itself is always
there in the upper right hand corner. How do I hide or disable it? I have
played around with options and startup options, looked in the help files to no
avail. Probably a pretty basic question for this forum, but your help would
be much appreciated.

Nick
Nov 13 '05 #1
5 3081
Nick250 wrote:
I have a simple app that I created for our Real Estate office using
Access 2000 and it is working fine except for on thing. I need to
keep the close button hidden from the users. No problem
accomplishing this it in forms using the forms properties. However
the close button for Access program itself is always there in the
upper right hand corner. How do I hide or disable it? I have played
around with options and startup options, looked in the help files to
no avail. Probably a pretty basic question for this forum, but your
help would be much appreciated.

Nick


I do it this way;

I declare a public variable;
Public vCloseApp As Boolean

In the Unload event of my main form, which is always open (important!), I
have this code;
------
Private Sub Form_Unload(Can cel As Integer)
On Error GoTo err_unload

If vCloseApp = False Then
Cancel = True
End If

exit_err_load:
Exit Sub

err_unload:
MsgBox Err.Description & " " & Err.number
Resume exit_err_load
End Sub
------
In the Load event I of the form I initialise the value of vCloseApp;
------
Private Sub Form_Load()
vCloseApp = False
End Sub
------
In the Exit button on that form I have this code;
---------
Private Sub cmdExit_Click()
On Error GoTo Err_cmdExit_Cli ck

vCloseApp = True
Response = MsgBox("Are you sure you wish to quit the application?",
vbQuestion + vbYesNo, "Quit")

If Response = 6 Then 'i.e yes, let's quit
DoCmd.Quit
ElseIf Response = 7 Then 'i.e no, I don't want to quit the app
vCloseApp = False
Exit Sub
End If

Exit_cmdExit_Cl ick:
Exit Sub

Err_cmdExit_Cli ck:
MsgBox Err.Description
Resume Exit_cmdExit_Cl ick

End Sub
-----------
Explanation;
------------
The app starts, the main form loads and vCloseApp is set to False.

If they click the Exit button like they should then I assume they want to
quit and set vCloseApp to True. However I then ask them to confirm this.
If they change their mind then it's set to False. The Unload event then
fires which checks the value of vCloseApp, if it's True then the app quits.

If someone tries to close the app using the X button the Unload event
catches this and checks the value of vCloseApp. If it's False then the event
is cancelled - the form does not unload and the app stays open. If it's
True then they've clicked the Exit button prior to the unload event firing,
all is well and the app quits.
Nov 13 '05 #2
ni*****@aol.com (Nick250) wrote in message news:<20******* *************** *****@mb-m11.aol.com>...

In the form's properties (format) set close box to no.

Neil
I have a simple app that I created for our Real Estate office using Access 2000
and it is working fine except for on thing. I need to keep the close button
hidden from the users. No problem accomplishing this it in forms using the
forms properties. However the close button for Access program itself is always
there in the upper right hand corner. How do I hide or disable it? I have
played around with options and startup options, looked in the help files to no
avail. Probably a pretty basic question for this forum, but your help would
be much appreciated.

Nick

Nov 13 '05 #3
NeilAnderson wrote:
ni*****@aol.com (Nick250) wrote in message
news:<20******* *************** *****@mb-m11.aol.com>...

In the form's properties (format) set close box to no.

Neil
I have a simple app that I created for our Real Estate office using
Access 2000 and it is working fine except for on thing. I need to
keep the close button hidden from the users. No problem
accomplishing this it in forms using the forms properties. However
the close button for Access program itself is always there in the
upper right hand corner. How do I hide or disable it? I have
played around with options and startup options, looked in the help
files to no avail. Probably a pretty basic question for this
forum, but your help would be much appreciated.

Nick


That won't help with the Access window itself to which the OP was referring.
Nov 13 '05 #4
>
Nick250 wrote:
I have a simple app that I created for our Real Estate office using
Access 2000 and it is working fine except for on thing. I need to
keep the close button hidden from the users. No problem
accomplishing this it in forms using the forms properties. However
the close button for Access program itself is always there in the
upper right hand corner. How do I hide or disable it? I have played
around with options and startup options, looked in the help files to
no avail. Probably a pretty basic question for this forum, but your
help would be much appreciated.

Nick


I do it this way;

I declare a public variable;
Public vCloseApp As Boolean

In the Unload event of my main form, which is always open (important!), I
have this code;
------
Private Sub Form_Unload(Can cel As Integer)
On Error GoTo err_unload

If vCloseApp = False Then
Cancel = True
End If

exit_err_loa d:
Exit Sub

err_unload:
MsgBox Err.Description & " " & Err.number
Resume exit_err_load
End Sub
------
In the Load event I of the form I initialise the value of vCloseApp;
------
Private Sub Form_Load()
vCloseApp = False
End Sub
------
In the Exit button on that form I have this code;
---------
Private Sub cmdExit_Click()
On Error GoTo Err_cmdExit_Cli ck

vCloseApp = True
Response = MsgBox("Are you sure you wish to quit the application?",
vbQuestion + vbYesNo, "Quit")

If Response = 6 Then 'i.e yes, let's quit
DoCmd.Quit
ElseIf Response = 7 Then 'i.e no, I don't want to quit the app
vCloseApp = False
Exit Sub
End If

Exit_cmdExit_C lick:
Exit Sub

Err_cmdExit_Cl ick:
MsgBox Err.Description
Resume Exit_cmdExit_Cl ick

End Sub
-----------
Explanation;
------------
The app starts, the main form loads and vCloseApp is set to False.

If they click the Exit button like they should then I assume they want to
quit and set vCloseApp to True. However I then ask them to confirm this.
If they change their mind then it's set to False. The Unload event then
fires which checks the value of vCloseApp, if it's True then the app quits.

If someone tries to close the app using the X button the Unload event
catches this and checks the value of vCloseApp. If it's False then the event
is cancelled - the form does not unload and the app stays open. If it's
True then they've clicked the Exit button prior to the unload event firing,
all is well and the app quits.


Deano, thank you for your reply. Perhaps you can help me refine this. What I
am really looking for is a "setting" or snipit of code that simply disables the
Access close button from the git go. The user never sees it, or if it is
visible, clicking on it would do nothing. (Perhaps a message box that says
"This Feature Unavaible"). Something that would run on startup, or in the load
event of my main form, like:

CloseButton=Fal se

Ideas? TIA

Nick
Nov 13 '05 #5
Nick

I think this is what you're looking for.

First create a new code module and paste the following ...
'*********
Option Compare Database

'The code below will do EXACTLY that for you (i.e. it will "disable
the 'X' in the actual Access window itself). I use this code in ALL my
applications.
'All you need to do is somewhere in your "startup routine" is to issue
the code line:
'EnableDisableC ontrolBox False
'Then in YOUR application "Close function/routines", simply issue the
code line:
'EnableDisableC ontrolBox True

Private Declare Function apiEnableMenuIt em Lib "user32" Alias _
"EnableMenuItem " (ByVal hMenu As Long, ByVal wIDEnableMenuIt em As
Long, _
ByVal wEnable As Long) As Long

Private Declare Function apiGetSystemMen u Lib "user32" Alias _
"GetSystemM enu" (ByVal hwnd As Long, ByVal Flag As Long) _
As Long

Function EnableDisableCo ntrolBox(bEnabl e As Boolean, _
Optional ByVal lhWndTarget As Long = 0) As Long

On Error GoTo ErrorHandling_E rr

' ----------------------------------------------------------------------
' Purpose: Example of how to disable or enable the control box of
' a form, report, or the Access parent window.
'
' Accepts: bEnable, which determines whether to disable or enable
' the control box
'
' Also accepts lhWndTarget (which is optional), if you want
' to use a window handle other than the Access parent window.
'
' Returns: N/A
'
' Example usage: lRetVal = EnableDisableCo ntrolBox(True) to enable
-OR-
' lRetVal = EnableDisableCo ntrolBox(False) to disable
'
' NOTE: If no hWnd is passed in for a specific form, then the code
' assumes you want to enable/disable the Access parent window
' ----------------------------------------------------------------------

Const MF_BYCOMMAND = &H0&
Const MF_DISABLED = &H2&
Const MF_ENABLED = &H0&
Const MF_GRAYED = &H1&
Const SC_CLOSE = &HF060&

Dim lhWndMenu As Long
Dim lReturnVal As Long
Dim lAction As Long

lhWndMenu = apiGetSystemMen u(IIf(lhWndTarg et = 0,
Application.hWn dAccessApp, lhWndTarget), False)

If lhWndMenu <> 0 Then
If bEnable Then
lAction = MF_BYCOMMAND Or MF_ENABLED
Else
lAction = MF_BYCOMMAND Or MF_DISABLED Or MF_GRAYED
End If
lReturnVal = apiEnableMenuIt em(lhWndMenu, SC_CLOSE, lAction)
End If

EnableDisableCo ntrolBox = lReturnVal

ErrorHandling_E rr:
If Err Then
'Trap your error(s) here, if any!
End If
End Function

'--------------------
'Rob Richards
'Archery Software Solutions
'*********
Next, paste the following code into the module behind your switchboard
form ...

'*********
Private Sub Form_Close()
Dim lRetVal As Long
lRetVal = EnableDisableCo ntrolBox(True)
End Sub

Private Sub Form_Open(Cance l As Integer)
Dim lRetVal As Long
lRetVal = EnableDisableCo ntrolBox(False)
End Sub
'*********

Then "Debug | Compile" and "File | Save" the module.

If I've explained it properly, it will disable the close button in the
top right corner.

Feel free to email me directly if you have trouble.

Kind Regards

Nathan
Nov 13 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
20777
by: moose | last post by:
OK Popup window? No problem PDF in popup? No problem But what about a couple of Close Window buttons? Imagine a "Close Window" button at the top of the popup page. Then the PDF which can scroll. And another "Close Window" button at the bottom of the page. Any suggestions for completing this task?
1
6944
by: dibyendu_k | last post by:
Hi, There is a problem i cant solve regarding Internet Explorer 5.5. It is regarding the Print Dialog Box. From a webpage if I open a popup window (window.open()) containing buttons Print and Close. The functionality is that when i press the "print" button the Print dialog box is opened (window.print();) and when I click on the close button...
1
1835
by: Ebrahim | last post by:
This message is in reply to a prev 1 . My application refues to close . Some one had suggested that I might have threads running.. but i solved that problem too . The app still refuses to close . !! Here is the code for one of them !! I call a stop function to disconnect all objects (close ) . I also make a call to Stop in the...
4
5498
by: Hitesh | last post by:
Hi, I am opening an Modal dialog box using the window.Showmodaldialogbox(), and in that window i am having an aspx form with say one ASP.NET Button control. i am doing some operation on the click event of the button control on the server and finally closing the window by using the following statement at the end of the click event of the...
2
1891
by: Bruce Wiebe | last post by:
hi all im having a problem accessing a text file on my hard disk after ive created it and added some text to it it would appear that the file is still locked. What happens is this i have three buttons on a windows form that provide three options for the user the process goes like this user clicks button one and a web service is called...
2
4321
by: Del | last post by:
I have a popup form that consist of a single field called EnteredBy and a Subform that has three fields. The popup form also has a button in the Form Footer called close. In the On Click event I have the following code. DoCmd.Close I want the EnteredBy field to be a required field. So in the On Exit event for that field I have the...
1
1277
by: somtabu | last post by:
hello, i have a problem in vb.net windows application, verson is 2005 and framework is 2.0 I want to close a form by using the close button which is right hand top side of the window. i want, when i click the close button a dialog box appear and ask me "Are you sure you want to Quit?" and there is 2 button (Yes and No).... if i click "Yes"...
2
3356
by: Bruce | last post by:
Hello, I have a form in an Access 2003 application which opens maximized. Its CloseButton property is set to false. On this form I have a command button that opens a report in preview mode. The report opens fine. It opens maximized as one would expect. However, the report preview window's close button is disabled which is confusing to...
5
5872
by: Tony | last post by:
I am continuing to develop an Access 2007 application which was originally converted from Access 2003. In Access 2003 I was able to disable the Access Close button in the top righthand corner of the screen. I have been unable to find any way to disable this button in Access 2007 and subsequently I have been forced to find ways to detect and...
0
7703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7930
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7681
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6290
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3662
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2118
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1229
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
950
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.