Results 1 to 5 of 5

Thread: Unloading help

  1. #1
    Join Date
    Nov 2005
    Posts
    113

    Unanswered: Unloading help

    Hello

    I would like to stop sub Unload when the fields are empty, I have a function that checks that. But if the User exits the program using the exit button (You know, the one on the top right corner in Windows) it doesn't work.
    Anyone know?

  2. #2
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    One way to stop this is to have a form level boolean variable, called let's say "booOkayToClose". When the form loads set it to false. In your normal exit procedure, set it to true if the field validation is successful. In the form's unload event, check that variable and if it's false set cancel = true (which will prevent the form from closing).
    Paul

  3. #3
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Or, of course, simply disable the Close Button. Under form Properties select Format, then set Close Button to NO>
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  4. #4
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    That will not get rid of the Access close button, only the form close button. The OP referred to the Access close button.
    Paul

  5. #5
    Join Date
    Nov 2005
    Posts
    113
    Thanks everyone. I found DoCmd.CancelEvent that did what I wanted.

    Cheers!

Posting Permissions

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