Hi Steve,
I've tried this but I can't get it to work. Where do I put the Private
Declare Function? I've copied your post straight into a module and
CloseButtonState(False) is called when my frmLogin is closed (this form stays
open all the time) - see below
Private Sub cmdExit_Click() 'this is called from Form_Close
If MsgBox("Are you sure you wish to exit the database?", vbQuestion &
vbYesNo) = vbYes Then
DoCmd.Close acForm, Me.Name
Call CloseButtonState(True) 'Enables X
Application.Quit
Else
Exit Sub
End If
End Sub
CloseButtonState(True) is called when the application is opened (i.e. on
frmLogin Form_Open)
However, I get the following error on open:
"The expression On Open you entered as the event property setting produced
the following error: Only comments may appear after End Sub, End Function, or
End Property."
Appreciate your help
"SteveM" wrote:
> If you want to disable it, put this in a module:
>
> Private Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As Long, _
> ByVal bRevert As Long) As Long
>
> 'Disable/Enable the Close Button Option
> Public Sub CloseButtonState(boolClose As Boolean)
> Dim hWnd As Long
> Dim wFlags As Long
> Dim hMenu As Long
> Dim Result As Long
>
> hWnd = Application.hWndAccessApp
> hMenu = GetSystemMenu(hWnd, 0)
> If Not boolClose Then
> wFlags = MF_BYCOMMAND Or MF_GRAYED
> Else
> wFlags = MF_BYCOMMAND And Not MF_GRAYED
> End If
>
> Result = EnableMenuItem(hMenu, SC_CLOSE, wFlags)
> End Sub
>
> Then in your code, maybe in a splash form:
> Call CloseButtonState(False) 'Disables X
> Call CloseButtonState(True) 'Enables X
>
> Don't forget to enable it when you close your app!
>
> Steve
>
> "Weste" wrote:
>
> > Is there any way to disable or remove the X at the applicaton level (top
> > right corner of app)? I want the users to exit the application by using my
> > menu and not at the application level. If there is no way to prevent users
> > from exiting the application using the X in the top right corner of Access,
> > is there an event to trap when this is clicked? Thanks.
> >
> > Weste
|