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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting Your Users to Properly Close Database

Status
Not open for further replies.

Bill6868

Technical User
Mar 20, 2007
96
US
Many of my database applications run action queries when the various screens close (via my Command buttons). If a user closes the application by clicking the Access “X” at the top of the screen, these event procedures don’t run, sometimes creating problems with the integrity of the data.

Is there any way to hide those three options at the top of the screen? Minimize, Restore Down and Close

I’d like the users to use the Command buttons I put on the forms for navigation and exiting the application. I have explained the reasons behind using the Command buttons but they will ignore anyway.

Any suggestions would be most appreciated.

Bill6868
 

Short of a baseball bat to the knees (you only have to do it once if you do it in front of the other users) there are a few things you can do.

If you put your code in the 'On Close' event it will run even if they 'X' out. If it is in the 'On Click' event of a button it won't. I would do this even if you hide the buttons.

Yes, you can hide those buttons -- set the Form Property 'Control Box' to 'No'.
 

Your users will 'X' out of your application because they can do it to any other application. Why yours should be any different? So, IMHO, they are not doing anything wrong. It is programmer's fault (well, you) not program corectly.


Have fun.

---- Andy
 
Thanks,

I had not thought of putting the code on the 'On Close' event. I always set the form's property 'control box' to 'no'. This will take the 'X' out of the form's title bar but I talking about Access' "X" at the top of the screen.

Have to admit, I did think about using the old baseball bat trick, but I'll take Gammachaser's advise and try the old 'On Close" event.

Thanks for your advice.

Bill

 
Oh... you mean the BIG 'X'... no, you can't hide that one (and you shouldn't.)

The On_Close Event should do the trick short of pulling the plug or hitting the Power Off switch.
 
[quite Gammachaser] Oh... you mean the BIG 'X'... no, you can't hide that one [/quote]

try this code
paste into a module and call HideAccessCloseButton
Code:
Public Declare Function SetWindowPos Lib "user32" (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long

Private Const HWND_TOP = 0
Private Const WS_SYSMENU = &H80000
Private Const GWL_STYLE = (-16)
Private Const SWP_FRAMECHANGED = &H20
Private Const SWP_DRAWFRAME = SWP_FRAMECHANGED
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1

Sub HideAccessCloseButton()

    Dim lngStyle As Long
    lngStyle = GetWindowLong(hWndAccessApp, GWL_STYLE)
    lngStyle = lngStyle And Not WS_SYSMENU
    Call SetWindowLong(hWndAccessApp, GWL_STYLE, lngStyle)
    Call SetWindowPos(hWndAccessApp, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE Or SWP_DRAWFRAME)
End Sub

Gammachaser said:
(and you shouldn't.)

Well why not
 
Quote (Gammachaser):
(and you shouldn't.)

Well why not

Only because people are used to seeing it (and using it) and there are ways of doing what he wants without hiding it.

I don't like taking users out of their comfort zones unless there is no choice.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top