How to hide the 'X' in right corner

russi

Registered User.
Local time
Today, 17:22
Joined
Jul 18, 2000
Messages
385
How to hide the 'X' in right corner? Can I?

Hi.
Here's the problem.
I have coding on forms that get processed when staff clicks on a Save & Exit button. However some staff invariably close the form by clicking on the 'X' in the upper right corner and the coding does not get processed, so some data is not saved.
How can I hide this 'X' or make them use the Save & Exit button?

Thanks in advance.

Russ
 
Sorry, but I might not have been clear or I might not be understanding your idea.

When a user is in a form, there is the the top bar that lists the database name and to the right has the Minimize, Maximize, and 'X' Close boxes.

WHAT I NEED TO DO is to hide/remove the next line that has File, Edit, View, Insert, .... and on the right the Minimize, Maximize, and 'X' box. (At least, to remove/hide that line's 'X' box.)

IF your idea was correct, can you be more specific as to where I find the option you suggested?

Russ
 
If you mean the close button on the title bar then I don't think you can remove it.
If you mean the default menu bar then you can create your own and use it in place of the default.
These settings are as Rich said in the startup options.
 
A few other ways, set the form to PopUp and maximize which will cover everything, or set the forms Modal property to yes which will prevent users from access to anything other than your form while it's open
 
Sure like both posters have said the property you are looking for is Control Box. Set it to no..this will get rid of the minimize / maximize as well.
Another way to get rid of the X is to use code:
Option Compare Database
Public Declare Function apiEnableMenuItem Lib "user32" Alias "EnableMenuItem" (ByVal hMenu As Long, ByVal wIDEnableMenuItem As Long, ByVal wEnable As Long) As Long
Public Declare Function apiGetSystemMenu Lib "user32" Alias "GetSystemMenu" (ByVal hWnd As Long, ByVal flag As Long) As Long

Public Function EnableDisableControlBoxX(bEnable As Boolean, Optional ByVal lhWndTarget As Long = 0) As Long

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 = apiGetSystemMenu(IIf(lhWndTarget = 0, Application.hWndAccessApp, 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 = apiEnableMenuItem(lhWndMenu, SC_CLOSE, lAction)
End If

EnableDisableControlBoxX = lReturnVal

End Function

To use this code either call it from an autoexec macro or the onactivate / onopen event of your form:

Private Sub Form_Activate()
EnableDisableControlBoxX (False)
End Sub

Shed some light?
Jon
 
Jon,
I know I must sound crazy. And who knows?!

But when I CHANGE THE CONTROL BOX STUFF THE x STILL WORKS AND SHOWS AS USUAL.

And after using your code the same poblem, although when leaving the form by the 'X', the very top 'X' which is on the database name line, disappears. Not the one with 'file, etc.

Is it my using Access 97?

Help!

Russ
 
Hi Russ,
You sure you changed the property of the control box to no and disabled the property close button to no? That code needs to be called first thing when the db opens. Is this form a pop up?
Jon
 
Russ,

With Access 97, in Design mode, set FORM properties:
Control Box = No
Min Max Buttons = None
Close Button = No

and

Border Style = Dialog

then you will have a FORM with no "X" in the upper right corner.

This always works.

RichM
 
Yes, I'm sure. Iget weird results on some screens.

Can I send you unpopulated version of the database?

Russ
 
yes, please zip it if it is large and unpopulate it and explain which form is giving you problems.
Jon
 
rIch,

I hate to say it, but it does not work here!

care to see sample of database?

Russ
 
Russi,
Never say never send the ol db my way and I'll perform some magic :).
Jon
 
Jon, 'real dummy time' but when I went to email you message, I saw no option for sending attachments.

???

Russ
 
Russ,

Dont you have hotmail / yahoo/ some other service for email? Are you using outlook? Drag and drop the db to the email message and send it. I haven't used the email feature in here..but usually when I click an e-mail address I have outlook open up and I can drop the attachement right there.

Jon
 
here it is in regular post - When I hit your profile email option there was no attachment feature (At least I know what that looks like!!!)

Thanks

Russ
 
The new format doesn't reveal your email directly..

Probably to hamper spam harvesters. What it does it has an online form for you to fill out and then it emails the person. You'll have to ask them for their email, or wait for a reply from them, in order to know it.
 
Russi,
I got your db but it had only one form in it. frmResolution...which changed my resolution!!! bad russi bad!!
;)

Send me the db with your forms :)
 
Ok,

I didn't realize this but you had hidden all of your objects. So I got it going. Again if you set the CONTROL BOX Property to no which I did the X and min/max buttons are gone. This is fine...but you need to distinguish a form from the Access menu bar at the top. I see what you are talking about when you say:
"But the X at the top wont go away". So the solution to this and there are 2. The first is to create your own Custom bar which is very simple to do. View->toolbars->customize ... and make sure you do not allow for the X. Give it a name and in the tools->startup options there is a menu bar option make sure you unselect "Default" and enter your own menu bar. You could always hide yours as well so that there is no menu bar.
The second solution is to use the code that I sent you. Create a macro autoexec and use the action to RunCode and use that function I supplied you with. Both work. I'd use the first option and create your own menu bar though and hide it.
As for your db...watch what you are forcing your users into. Especially the resolution change...you really shouldn't use this. Look into tools such as ShrinkerStretcher by Peter DeBaets who has create a tool that automatically rescales forms of any size. Its like 20 bucks but its well worth it.
Jon
 

Users who are viewing this thread

Back
Top Bottom