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
-
InfoStealer Malware Data Breach Exposed 184 Million Logins and Passwords
by
Alex5723
7 hours, 46 minutes ago -
How well does your browser block trackers?
by
n0ads
2 hours, 34 minutes ago -
You can’t handle me
by
Susan Bradley
4 hours, 23 minutes ago -
Chrome Can Now Change Your Weak Passwords for You
by
Alex5723
3 hours, 26 minutes ago -
Microsoft: Over 394,000 Windows PCs infected by Lumma malware, affects Chrome..
by
Alex5723
19 hours, 8 minutes ago -
Signal vs Microsoft’s Recall ; By Default, Signal Doesn’t Recall
by
Alex5723
6 hours, 41 minutes ago -
Internet Archive : This is where all of The Internet is stored
by
Alex5723
19 hours, 32 minutes ago -
iPhone 7 Plus and the iPhone 8 on Vantage list
by
Alex5723
19 hours, 37 minutes ago -
Lumma malware takedown
by
EyesOnWindows
7 hours, 53 minutes ago -
“kill switches” found in Chinese made power inverters
by
Alex5723
1 day, 4 hours ago -
Windows 11 – InControl vs pausing Windows updates
by
Kathy Stevens
1 day, 4 hours ago -
Meet Gemini in Chrome
by
Alex5723
1 day, 8 hours ago -
DuckDuckGo’s Duck.ai added GPT-4o mini
by
Alex5723
1 day, 8 hours ago -
Trump signs Take It Down Act
by
Alex5723
1 day, 16 hours ago -
Do you have a maintenance window?
by
Susan Bradley
31 minutes ago -
Freshly discovered bug in OpenPGP.js undermines whole point of encrypted comms
by
Nibbled To Death By Ducks
18 hours, 44 minutes ago -
Cox Communications and Charter Communications to merge
by
not so anon
1 day, 19 hours ago -
Help with WD usb driver on Windows 11
by
Tex265
4 hours, 14 minutes ago -
hibernate activation
by
e_belmont
2 days, 4 hours ago -
Red Hat Enterprise Linux 10 with AI assistant
by
Alex5723
2 days, 8 hours ago -
Windows 11 Insider Preview build 26200.5603 released to DEV
by
joep517
2 days, 11 hours ago -
Windows 11 Insider Preview build 26120.4151 (24H2) released to BETA
by
joep517
2 days, 11 hours ago -
Fixing Windows 24H2 failed KB5058411 install
by
Alex5723
1 day, 7 hours ago -
Out of band for Windows 10
by
Susan Bradley
2 days, 16 hours ago -
Giving UniGetUi a test run.
by
RetiredGeek
2 days, 23 hours ago -
Windows 11 Insider Preview Build 26100.4188 (24H2) released to Release Preview
by
joep517
3 days, 6 hours ago -
Microsoft is now putting quantum encryption in Windows builds
by
Alex5723
1 day, 2 hours ago -
Auto Time Zone Adjustment
by
wadeer
3 days, 11 hours ago -
To download Win 11 Pro 23H2 ISO.
by
Eddieloh
3 days, 9 hours ago -
Manage your browsing experience with Edge
by
Mary Branscombe
9 hours, 1 minute 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.