I have created a run-time version and have reports that are generated when clicking a button. The report displays in print preview mode. The report has a custom menubar with two choices: print and close. When closing the report, either by clicking the “close” button of the “X” box in the upper right corner of the report print preview, the user is returned to the main menu. If the second “X” box in the far right upper corner is clicked, the complete program is shut down and the user is returned to the desktop. How can I disable the second “X” box?
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
-
Report closing in run-time mode (A97SR2)
Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Report closing in run-time mode (A97SR2)
- This topic has 8 replies, 4 voices, and was last updated 22 years, 10 months ago.
Viewing 1 reply threadAuthorReplies-
WSMarkLiquorman
AskWoody LoungerJuly 11, 2002 at 4:23 pm #600549I believe you are talking about the “x” that is part of the Access window itself. I don’t think there is a way to diasable that. If you had a hidden form with code in its OnClose event, you might be able to Cancel the event if some conditions weren’t met. For example, your usual Exit Application button might set a global field to Yes; so if that variable wasn’t Yes, you’d know some other form of Exit was selected.
-
WScharlotte
AskWoody Lounger -
WSMarkLiquorman
AskWoody Lounger
-
-
-
WSHansV
AskWoody LoungerJuly 12, 2002 at 6:38 am #600676Microsoft has a KB article on this: ACC2000: How to Disable the Close Button (X) on the Access Application Window (Q245746)
I also found the following code in my collection. I didn’t write it myself, but I don’t know where I got it from (Calvin Smith?)
To disable the close button of the Access application window, useSetControlBox False
‘ We need the following API declarations first
Private Declare Function apiEnableMenuItem Lib “user32” Alias _
“EnableMenuItem” _
(ByVal hMenu As Long, _
ByVal wIDEnableMenuItem As Long, _
ByVal wEnable As Long) As LongPrivate Declare Function apiGetSystemMenu Lib “user32” Alias _
“GetSystemMenu” _
(ByVal hWnd As Long, _
ByVal flag As Long) As LongFunction SetControlBox(bEnable As Boolean, Optional ByVal lhWndTarget As Long = 0) As Long
‘ Purpose: disable or enable the control box of a form, report
‘ or the Access parent window.‘ Arguments:
‘ bEnable: whether to disable or enable the control box.
‘ lhWndTarget (optional), for a window other then the Access parent window.‘ Returns: 0 if disabled, 3 if enabled
‘ Example usage:
‘ lRetVal = SetControlBox(True) to enable -OR-
‘ lRetVal = SetControlBox(False) to disable‘ NOTE: If no hWnd is passed in for a specific form, then the code
‘ assumes you want to enable/disable the close box of the Access app windowConst 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 LongOn Error GoTo ErrorHandling_Err
lhWndMenu = apiGetSystemMenu(IIf(lhWndTarget = 0, _
Application.hWndAccessApp, lhWndTarget), False)If lhWndMenu 0 Then
If bEnable Then
lAction = MF_ENABLED
Else
lAction = MF_DISABLED Or MF_GRAYED
End If
lReturnVal = apiEnableMenuItem(lhWndMenu, SC_CLOSE, lAction)
End IfSetControlBox = lReturnVal
Exit Function
ErrorHandling_Err:
If Err Then
‘ Trap your error(s) here, if any!
End If
End Function -
WSRonM
AskWoody LoungerJuly 12, 2002 at 2:20 pm #600750Thank you for any and all help provided.
First I must admit that I am not a programming guru.
Attempted to duplicate the KB article (Q245746). Everything was accepted by the program but It did not return the desired results. Went through the Step-by-Step Example on a copy of my program and when starting the program, was presented with the following message box:
(your program) can’t find the name ‘Function’ you entered in the expression.
You may have specified a control that wasn’t on the current object without specifying the correct form or report context.
To refer to a control on another form or report, precede the control name with the name of a collection, usually either Forms or Reports, and the name of the form or report to which the control belongs. For example, Forms![Products]![Units In Stock].
Was this example designed for A2000 and does not work on A97?
Was there an assumption of additional information that needs to be entered in order for the function to work?
I don’t know.Thanks again.
-
WSHansV
AskWoody LoungerJuly 12, 2002 at 2:39 pm #600756 -
WSRonM
AskWoody LoungerJuly 12, 2002 at 3:23 pm #600779It works just fine!
Thank you very much for your assistance.
You did it again.The malfunction was caused by the defect midway between my two ears. Under the Action Arguments I had typed: Function Name: InitApplication(). After removing the (Function Name:) it worked great.
You may now proceed to ROFL.
-
WSHansV
AskWoody Lounger
-
-
-
-
Viewing 1 reply thread -

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
Auto Time Zone Adjustment
by
wadeer
1 hour, 10 minutes ago -
To download Win 11 Pro 23H2 ISO.
by
Eddieloh
6 hours, 22 minutes ago -
Manage your browsing experience with Edge
by
Mary Branscombe
7 hours ago -
Fewer vulnerabilities, larger updates
by
Susan Bradley
54 minutes ago -
Hobbies — There’s free software for that!
by
Deanna McElveen
3 hours, 12 minutes ago -
Apps included with macOS
by
Will Fastie
2 hours, 5 minutes ago -
Xfinity home internet
by
MrJimPhelps
11 hours, 52 minutes ago -
Convert PowerPoint presentation to Impress
by
RetiredGeek
5 minutes ago -
Debian 12.11 released
by
Alex5723
22 hours, 18 minutes ago -
Microsoft: Troubleshoot problems updating Windows
by
Alex5723
1 day, 2 hours ago -
Woman Files for Divorce After ChatGPT “Reads” Husband’s Coffee Cup
by
Alex5723
5 hours, 26 minutes ago -
Moving fwd, Win 11 Pro,, which is best? Lenovo refurb
by
Deo
22 hours, 28 minutes ago -
DBOS Advanced Network Analysis
by
Kathy Stevens
1 day, 18 hours ago -
Microsoft Edge Launching Automatically?
by
healeyinpa
1 day, 9 hours ago -
Google Chrome to block admin-level browser launches for better security
by
Alex5723
1 day, 21 hours ago -
iPhone SE2 Stolen Device Protection
by
Rick Corbett
1 day, 13 hours ago -
Some advice for managing my wireless internet gateway
by
LHiggins
21 hours, 24 minutes ago -
NO POWER IN KEYBOARD OR MOUSE
by
HE48AEEXX77WEN4Edbtm
14 hours, 15 minutes ago -
A CVE-MITRE-CISA-CNA Extravaganza
by
Nibbled To Death By Ducks
2 days, 7 hours ago -
Sometimes I wonder about these bots
by
Susan Bradley
2 days, 3 hours ago -
Does windows update component store “self heal”?
by
Mike Cross
1 day, 17 hours ago -
Windows 11 Insider Preview build 27858 released to Canary
by
joep517
2 days, 21 hours ago -
Pwn2Own Berlin 2025: Day One Results
by
Alex5723
1 day, 4 hours ago -
Windows 10 might repeatedly display the BitLocker recovery screen at startup
by
Susan Bradley
17 hours, 37 minutes ago -
Windows 11 Insider Preview Build 22631.5409 (23H2) released to Release Preview
by
joep517
2 days, 23 hours ago -
Windows 10 Build 19045.5912 (22H2) to Release Preview Channel
by
joep517
2 days, 23 hours ago -
Kevin Beaumont on Microsoft Recall
by
Susan Bradley
2 days, 12 hours ago -
The Surface Laptop Studio 2 is no longer being manufactured
by
Alex5723
3 days, 7 hours ago -
0Patch, where to begin
by
cassel23
3 days, 1 hour ago -
CFPB Quietly Kills Rule to Shield Americans From Data Brokers
by
Alex5723
3 days, 21 hours ago
Recent blog posts
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.