Calvin Smith http://www.CalvinSmithSoftware.com/codedisk/sneakpeek.htm '********************************************************** '************ Code provided by CodeDisk II **************** '********************************************************** '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 Long Private Declare Function apiGetSystemMenu Lib "user32" Alias _ "GetSystemMenu" (ByVal hWnd As Long, ByVal flag As Long) _ As Long Function EnableDisableControlBox(bEnable As Boolean, _ Optional ByVal lhWndTarget As Long = 0) As Long On Error GoTo ErrorHandling_Err ' ---------------------------------------------------------------------- ' Purpose: Example of how to disable or enable the control box of ' a form, report, or the Access parent window. ' ' Accepts: bEnable, which determines whether to disable or enable ' the control box ' ' Also accepts lhWndTarget (which is optional), if you want ' to use a window handle other than the Access parent window. ' ' Returns: N/A ' ' Example usage: lRetVal = EnableDisableControlBox(True) to enable -OR- ' lRetVal = EnableDisableControlBox(False) to disable ' ' NOTE: If no hWnd is passed in for a specific form, then the code ' assumes you want to enable/disable the Access parent window ' ---------------------------------------------------------------------- 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 EnableDisableControlBox = lReturnVal ErrorHandling_Err: If Err Then 'Trap your error(s) here, if any! End If End Function