Results 1 to 10 of 10
  1. #1
    4 Star Lounger
    Join Date
    Feb 2002
    Posts
    537
    Thanks
    0
    Thanked 0 Times in 0 Posts

    forbid closing the form? (Access 2000)

    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.How can i do it ? Obviously i have to build an If..Else clause
    in the OnClause event ?

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

    Re: forbid closing the form? (Access 2000)

    See the thread starting with <post#=301348>post 301348</post#>. <!profile=Ready4Data>Ready4Data<!/profile> attached a demo database to his reply that shows how to do this.

  3. #3
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Virginia, USA
    Posts
    1,560
    Thanks
    37
    Thanked 1 Time in 1 Post

    Re: forbid closing the form? (Access 2000)

    I'm not a programmer by trade (just trying to look like one <img src=/S/wink.gif border=0 alt=wink width=15 height=15> with a lot of help from sho-nuff guys like Hans), but here's my two cents:

    I'll assume you've got this application set up on a network, and that you've split it. Why not set up the FE so as not to allow the usual menus and toolbars. Then the user has no choice but to use the command button to close the form.

  4. #4
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Virginia, USA
    Posts
    1,560
    Thanks
    37
    Thanked 1 Time in 1 Post

    Re: forbid closing the form? (Access 2000)

    Hello, Hans: Just trying to understand what's going on here. Why might I want or need to go to all the trouble to set up this elaborate scheme to which you refer? I'm sure there must be a good reason

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

    Re: forbid closing the form? (Access 2000)

    Lucas,

    If the user changes the sort order in a form, then clicks the close button in the upper right corner, Access will try to save the form design without asking (changing the sort order counts as a design change.) In a multi-user environment this can cause problems. Therefore it is better to close the form using a command button that executes code

    DoCmd.Close acForm, Me.Name, acSaveNo

    Clicking the close button may also bypass cleaning-up actions that need to be performed.

  6. #6
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Virginia, USA
    Posts
    1,560
    Thanks
    37
    Thanked 1 Time in 1 Post

    Re: forbid closing the form? (Access 2000)

    I see. Now, on the other hand, what can go wrong if I take the precautions I mentioned in my earlier post, i.e., set up the FE so as to hide all those other menus and buttons? To my amateur's eyes, that appears to be as effective, although I still would not have the code that includes the instructions, "acSaveNo." I guess that's the big difference.

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

    Re: forbid closing the form? (Access 2000)

    In many cases, the standard measures will be sufficient. Still, if you leave a hole unplugged, users will eventually find it (probably unintentionally, but they will find it).

    When I started creating Access databases to be used by multiple users, they used to become corrupt from time to time. Since I started preventing users from "just" closing forms, I have hardly had corrupted databases any more.

  8. #8
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: forbid closing the form? (Access 2000)

    Hi Hans

    You said:

    <If the user changes the sort order in a form, then clicks the close button in the upper right corner, Access will try to save the form design without asking (changing the sort order counts as a design change.) In a multi-user environment this can cause problems. Therefore it is better to close the form using a command button that executes code>

    As Lucas, said with FE on client and BE on server, does it matter if user changes sort order and saves the design changes to client FE?

    I'm still learning with Lucas

    Thanks' John

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

    Re: forbid closing the form? (Access 2000)

    No, that's true.

    There are other reasons though; they all boil down that I have found that users saving the design of forms and reports can cause all kinds of problems, even when they are the only user in a local front end. the form or report may start to behave differently, and then they will come to me complaining that my form doesn't work correctly (if it works OK, it is "their" form, if there is a problem, it is "my" form.)

  10. #10
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: forbid closing the form? (Access 2000)

    I have to side with Hans on this. Users should *never* be allowed to make design changes to any of the objects in the application. That is not to say that the code in the application shouldn't make design changes behind the scenes, but letting a user do it is just asking for trouble ... and experience tells me that trouble is exactly what you'll get.

    In addition to the things Hans already pointed out, there are cleanup routines in forms modules that destroy object variables set in code. If you *don't* execute that code, it's possible that your application with suffer from memory leaks and insufficient memory errors, in addition to the possibility that it will simply hang because of objects that should have gone out of scope but didn't. <img src=/S/hairout.gif border=0 alt=hairout width=31 height=23>
    Charlotte

Posting Permissions

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