Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2004
    Posts
    52

    Unanswered: Prevent a form from closing

    How can I prevent a form from closing? The following code doesn't work (it shows the msgbox but still closes).

    private sub form_close()
    msgbox("bla")
    docmd.cancelevent
    end sub

    thanks

  2. #2
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    You can deactivate the close button on the Form. SetForm/properties/CloseButton to NO

  3. #3
    Join Date
    Mar 2004
    Posts
    52
    OK, I guess I oversimplified my case.

    The fact that the user can close the form depends on the contents of some (unbound) fields on the form (i.e. they have to be filled in).

    The solution you propose would completely disable the user from closing the form (unless I arrange this in my code, which I will do if there is no other solution).

    Thx,
    Phil

  4. #4
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Originally posted by ptrapp
    OK, I guess I oversimplified my case.

    The fact that the user can close the form depends on the contents of some (unbound) fields on the form (i.e. they have to be filled in).

    The solution you propose would completely disable the user from closing the form (unless I arrange this in my code, which I will do if there is no other solution).

    Thx,
    Phil
    In your Form_Unload method test for your exit criteria and if not met cancel the method (Set Cancel = 1 or greater)

  5. #5
    Join Date
    Mar 2004
    Posts
    52
    Thanks!!!

Posting Permissions

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