Results 1 to 4 of 4
  1. #1
    New Lounger
    Join Date
    Dec 2000
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Run code on close (Access 97)

    How can I have code automatically run when I close my database?

    For example, an autoexec macro that runs on the closure of the database.

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

    Re: Run code on close (Access 97)

    There is no AutoClose macro capability in Access. However, the way this is usually done if to open a form when the database is opened and keep it open and hidden throughout the session. In that form, you have an OnClose event that runs the code or macro you wish to run when your database closes. Make the last thing in that code or macro a DoCmd.Close that closes the form itself to insure that Access is able to close completely, since an open object, especially a hidden form, can cause Access to close the database but keep the process open.
    Charlotte

  3. #3
    New Lounger
    Join Date
    Nov 2001
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Run code on close (Access 97)

    Hi charlotte,

    Does this work regardless of how the db is closed? (file-exit, or wondows X)

    I generallly add an exit button to the main form that my users see, which executes a macro that does whatever housekeeping is necessary. Of course, I develop these things for users that are not pc literate.

    W

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

    Re: Run code on close (Access 97)

    In order for the database to close, the form has to close. When the form is closed, the code should execute, regardless of what specific action closes the form.
    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
  •