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]