Results 1 to 2 of 2
  1. #1
    3 Star Lounger
    Join Date
    Apr 2003
    Location
    Calgary, Alberta
    Posts
    327
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Change Function of Close (x) (Access 2000)

    Is there a way to change the default close method that the X does in the top right hand corner? If so, how do you access what code that x does for a specific form?

    Thanks

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Change Function of Close (x) (Access 2000)

    1. You can disable the "close" button by setting the Close Button property of a form to No.

    2. When the user closes a form, three events occur: On Unload, On Deactivate and On Close. The On Unload event has a Cancel argument that you can set to True if you want to prevent the user from closing the form. For example:

    Private Sub Form_Unload(Cancel As Integer)
    ' Test if txtSomething has been filled in by the user
    If IsNull(Me.txtSomething) Then
    ' Inform user
    MsgBox "You can't close the form if the Something field is empty", vbExclamation
    ' Put blinking cursor in empty text box
    txtSomething.SetFocus
    ' Cancel closing the form
    Cancel = True
    End If
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •