View Single Post
  #3  
Old May 18th, 2010, 05:10 PM posted to microsoft.public.access.forms
McHammer
external usenet poster
 
Posts: 4
Default How to prevent form from closing



"BruceM via AccessMonster.com" wrote:

It usually helps to post the actual code when there is a question about the
code. Why show them the X button (top right corner, not left, but I assume
you meant that) at all? You should be able to use the form's Property Sheet
to set Control Box to No (or set it to Yes, with MinMax buttons set to Yes
and Close Button to No if you want to keep the minimize and maximize buttons),
or you could set Border Style to None.

It may be possible, from what I can tell, to put something together to get
rid of the error message when the X button is clicked, but it would be a lot
of work for something that doesn't work as well as what you could have with
your own command buttons.

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/201005/1

.

Yes, "X" on the right...
Form is modal popup type, no min/max button, dialog, ctrl box yes.
Here below the code

Public MyAction As Variant

I've added MyAction = "save" to Save button and MyAction = "Cancel" to
Cancel button On click events

Private Sub Form_Current()
MyAction = Null
End Sub

Private Sub Form_BeforeUpdate(Cancel As Integer)
Select Case MyAction
Case "Cancel"
'do nothing
Case "Save"
'do nothing
Case Else
MsgBox "Push Save or Cancel", vbOKOnly
Cancel = True
Exit Sub
End Select
End Sub

In this way, if a new record is entered it's possible to "save & close" the
form or "cancel" a partial unwanted data and then close the form with "X"
button. If you try to close the form with unwanted data through "X" button,
Cancel = True should stop any other event, or at least it was my target.