Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disable Close button on a Customized MenuBar 1

Status
Not open for further replies.

eclipse33

Programmer
Apr 13, 2001
94
0
0
CA
Hi all,

I want to disable the close(x) button on the customized menubar of my form.

Here is what I have tried (neither has worked)
1) Form(properties) - Border Style = None
2) Form(properties) - Control Box = no
3) Form(properties) - Close Button = no
4) MenuBar(properties) - Docking = Can't Change
and every other option under the Customize MenuBar options

Anyone....

Or...is there a way not to have a menubar...I really don't need one anyway.

Thanks (weekend is almost here... [cheers]
eclipse33

 
Hiya,

Have you tried Tools->Customise->Toolbars tab and then ticked off Menu bar? (After opening your Access app for design).

Just a suggestion - I need 10 more years for this cr#@p.

Regards,

Darrylle "Never argue with an idiot, he'll bring you down to his level - then beat you with experience."
 
Maybe this will do what you need. I posted this in another thread about a similar situation.

I wish I could take credit for thinking of a simple solution like this, but I can't since I came across this in my reading. Although the above may work, here is a KISS way to do what you want regardless of toolbars, menubars, etc. are showing.

1. Declare a Public var such as Dim AllowClose As Boolean

2. In the On Load event on your form, set AllowClose = False

3. In the Click or DoubleClick event on your Exit command
button, set AllowClose = True and do a DoCmd.Close which
which will close the form

4. In the On Unload event on your form notice there is a
parameter Cancel - Set Cancel = Not AllowClose

The reason this works is because the Unload event (as opposed to the Close event) passes the Cancel parameter. If cancel is set to true, then the form cannot be unloaded no matter what keys are pressed or buttons are clicked. That's why you don't have to worry about closing off of a menu or toolbar. It doesn't matter. If AllowClose = False then Cancel will be true and the form will NOT unload.

Events that pass the cancel parameter come in handy. Other examples for form controls include before update and on exit. If you set cancel to true, the control cannot lose focus no matter what the user did. If you want to restore the original value, put controlname.undo somewhere in the validation code before you cancel.

Have a great night all, it's been a long day!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top