Connecting Tech Pros Worldwide Forums | Help | Site Map

forbid closing the form ?

Peter yeshew
Guest
 
Posts: n/a
#1: Nov 12 '05

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!

PC Datasheet
Guest
 
Posts: n/a
#2: Nov 12 '05

re: forbid closing the form ?


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" <freelance@abv.bg> wrote in message
news:3f8c1e2e$0$202$75868355@news.frii.net...[color=blue]
>
> 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![/color]


paii
Guest
 
Posts: n/a
#3: Nov 12 '05

re: forbid closing the form ?


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

"Peter yeshew" <freelance@abv.bg> wrote in message
news:3f8c1e2e$0$202$75868355@news.frii.net...[color=blue]
>
> 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![/color]


Trevor Best
Guest
 
Posts: n/a
#4: Nov 12 '05

re: forbid closing the form ?


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

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

--
A)bort, R)etry, I)nfluence with large hammer.
Trevor Best
Guest
 
Posts: n/a
#5: Nov 12 '05

re: forbid closing the form ?


On 14 Oct 2003 16:02:54 GMT in comp.databases.ms-access, Peter yeshew
<freelance@abv.bg> wrote:
[color=blue]
>
>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 ?[/color]

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.
Michel
Guest
 
Posts: n/a
#6: Nov 12 '05

re: forbid closing the form ?


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:<6i35pvga5mr5a3cesim7ub5d800dfn747k@4ax.com>. ..[color=blue]
> On 14 Oct 2003 16:02:54 GMT in comp.databases.ms-access, Peter yeshew
> <freelance@abv.bg> wrote:
>[color=green]
> >
> >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 ?[/color]
>
> 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.[/color]
Closed Thread