By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,122 Members | 927 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,122 IT Pros & Developers. It's quick & easy.

forbid closing the form ?

P: n/a

Is it possible to forbid closing the form through the File- Close menu ?
On my form i have a command button called CmdDeleteInvoice. When this
command button is visible ,i want to forbid the user from closing the
form through the menu commands file-close.I want to make him click the
button and not to allow him to do any other actions.And to disalloe the
forbid comand if the button is clisked.How can i do it ? Obviously i
have to build an If..Else clause
in the OnClause event ?
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Put this code in the UnLoad event of your form:

If Me!CmdDeleteInvoice.Visible = True Then
MsgBox "Please Delete The Invoice Before Closing The Form",,"Attention!"
Cancel = True
Me!CmdDeleteInvoice.SetFocus
End If
--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
www.pcdatasheet.com
"Peter yeshew" <fr*******@abv.bg> wrote in message
news:3f*********************@news.frii.net...

Is it possible to forbid closing the form through the File- Close menu ?
On my form i have a command button called CmdDeleteInvoice. When this
command button is visible ,i want to forbid the user from closing the
form through the menu commands file-close.I want to make him click the
button and not to allow him to do any other actions.And to disalloe the
forbid comand if the button is clisked.How can i do it ? Obviously i
have to build an If..Else clause
in the OnClause event ?
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 12 '05 #2

P: n/a
You may need rethink your structure. What's to stop a user from turning off
the computer? Will this break you app?

"Peter yeshew" <fr*******@abv.bg> wrote in message
news:3f*********************@news.frii.net...

Is it possible to forbid closing the form through the File- Close menu ?
On my form i have a command button called CmdDeleteInvoice. When this
command button is visible ,i want to forbid the user from closing the
form through the menu commands file-close.I want to make him click the
button and not to allow him to do any other actions.And to disalloe the
forbid comand if the button is clisked.How can i do it ? Obviously i
have to build an If..Else clause
in the OnClause event ?
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 12 '05 #3

P: n/a
On Wed, 15 Oct 2003 11:11:42 -0500 in comp.databases.ms-access, "paii"
<pa**@packairinc.com> wrote:
You may need rethink your structure. What's to stop a user from turning off
the computer? Will this break you app?


It's impossible, haven't you seen Wargames? :-)

--
A)bort, R)etry, I)nfluence with large hammer.
Nov 12 '05 #4

P: n/a
On 14 Oct 2003 16:02:54 GMT in comp.databases.ms-access, Peter yeshew
<fr*******@abv.bg> wrote:

Is it possible to forbid closing the form through the File- Close menu ?
On my form i have a command button called CmdDeleteInvoice. When this
command button is visible ,i want to forbid the user from closing the
form through the menu commands file-close.I want to make him click the
button and not to allow him to do any other actions.And to disalloe the
forbid comand if the button is clisked.How can i do it ? Obviously i
have to build an If..Else clause
in the OnClause event ?


If deleting the invoice is the only course of action that can be
accomplished then why have a button to do it? Just delete it in the
close event of the form.

--
A)bort, R)etry, I)nfluence with large hammer.
Nov 12 '05 #5

P: n/a
My answer to your problem got posted as a new message and not a
follow-up to this one:

Yes, there is a way of forbidding a form being closed if you create a
boolean variable (blnCanClose) in the form's Open and Unload event. I
didn't read all the responses, but I have just such a form that cannot
be closed using the close button. They must first select a button,
then the form closes. Here's the skeleton code:

In general declarations of form: Dim blnCanClose As Boolean

Private Sub Form_Open(Cancel As Integer)
' make sure bln is always false when form is opened
' can't be closed until variable = true
blnCanClose = False
End Sub

Private Sub Form_Unload(Cancel As Integer)
If blnCanClose = False Then
MsgBox "Please Select a Date!"
' input person needs to select a date
' code then uses selected date to perform something
' call function or press a command button
Cancel = True
Else
Cancel = False
End If
End Sub

Private Sub cmdPerformFunction_Click()
' code for whatever you want performed from this form
' variable = true, form can now be closed after function executed
blnCanClose = True

' close the form after this button is pressed
DoCmd.Close acForm, Me.Name

End Sub

Trevor Best <bouncer@localhost> wrote in message news:<6i********************************@4ax.com>. ..
On 14 Oct 2003 16:02:54 GMT in comp.databases.ms-access, Peter yeshew
<fr*******@abv.bg> wrote:

Is it possible to forbid closing the form through the File- Close menu ?
On my form i have a command button called CmdDeleteInvoice. When this
command button is visible ,i want to forbid the user from closing the
form through the menu commands file-close.I want to make him click the
button and not to allow him to do any other actions.And to disalloe the
forbid comand if the button is clisked.How can i do it ? Obviously i
have to build an If..Else clause
in the OnClause event ?


If deleting the invoice is the only course of action that can be
accomplished then why have a button to do it? Just delete it in the
close event of the form.

Nov 12 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.