[AccessD] Removing Exit ability

John W. Colby jwcolby at colbyconsulting.com
Thu Apr 8 09:08:13 CDT 2004


Access cannot close if it cannot close all forms.

1) In the form with your button, create a boolean variable in the code
header.
2) In the form Open set the boolean false - in fact it will already be false
but still... that's the theory.
3) In the form's Unload check if the bln is true and if not set cancel =
true.  This prevents the form closing thus prevents Access closing.
4) In the command button to close the form, set the boolean true (allow the
close) then run the code that closes Access.

dim blnAllowClose as boolean

Private Sub Form_Open(Cancel As Integer)
    	blnAllowClose =false
End Sub

Private Sub Form_Unload(Cancel As Integer)
    	if blnAllowClose = false then
		cancel = true
    	end if
End Sub

Private Sub cmdClose_Click()
On Error GoTo Err_cmdClose_Click

	blnAllowClose = true
	Application.Quit acQuitSaveNone

Exit_cmdClose_Click:
    Exit Sub

Err_cmdClose_Click:
    MsgBox Err.Description
    Resume Exit_cmdClose_Click

End Sub

John W. Colby
www.ColbyConsulting.com

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Gowey Mike W
Sent: Thursday, April 08, 2004 9:46 AM
To: Access Developers discussion and problem solving
Subject: [AccessD] Removing Exit ability



Hi Everyone,

Could anyone please tell me how I can remove the ability for the user to
click on the X to close Access, I want them to only be able to use the
buttons I have created on the forms to exit the program.

Thanks for any help.


Mike Gowey, MCSA, A+, ACE
Team Leader - SRCI
Information Systems & Services Division



--
_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com






More information about the AccessD mailing list