Closing Access 2000

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Nathan Bloom

    #1

    Closing Access 2000

    Is there a way to force the user of a database to exit and close access
    through a close button on for example a switchboard menu?

    If a user closes access by the exit command or the close button on access,
    this will prevent certain housekeeping routines to function unless thay quit
    through the database. Another alternative would be to also hook these
    functions to the close button on access or the exit command (file menu).

    Thank you in advance for any information in accomplishing this.
    Nathan Bloom


  • Terry Kreft

    #2
    Re: Closing Access 2000

    The trick with this is that Access cannot close unless all the forms,
    reports etc are closed.

    So what you do is have a form which only closes if a form variable is set to
    a particular value

    A simple example

    1) Create a new database
    2) Create a form in the database (Form1)

    3) Create a command button on the form (Command1)

    4) Add the following code to the form module

    ' *************** *************** *******
    ' Code start
    Private blnCanUnload As Boolean

    Private Sub Command0_Click( )
    blnCanUnload = True
    MsgBox "Clean Up Code here"
    DoCmd.Close acForm, Me.Name, acSavePrompt
    DoCmd.Quit acQuitPrompt
    End Sub

    Private Sub Form_Load()
    blnCanUnload = False
    End Sub

    Private Sub Form_Unload(Can cel As Integer)
    Cancel = Not blnCanUnload
    If Cancel Then
    MsgBox "Click the command button before you can unload Access"
    End If
    End Sub
    ' Code end
    ' *************** *************** *******

    4) Save the form

    Now with the form open
    a) click the close button on the access window
    (you'll get the message about clicking the command button)
    b) click the command button on the form
    c) click the close button on the access window
    (you get the message about clean up code and access closes)


    Terry

    "Nathan Bloom" <natebloom@eart hlink.net> wrote in message
    news:0H5qb.985$ Z25.638@newsrea d4.news.pas.ear thlink.net...[color=blue]
    > Is there a way to force the user of a database to exit and close access
    > through a close button on for example a switchboard menu?
    >
    > If a user closes access by the exit command or the close button on access,
    > this will prevent certain housekeeping routines to function unless thay[/color]
    quit[color=blue]
    > through the database. Another alternative would be to also hook these
    > functions to the close button on access or the exit command (file menu).
    >
    > Thank you in advance for any information in accomplishing this.
    > Nathan Bloom
    >
    >[/color]


    Comment

    Working...