Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Posts
    294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    closing a form at shut down (Access 2000)

    Is the a way to make sure a form is closed before db shuts down. Can some code be written to make sure the form closes then the db shuts down? It would need to be a global type. The form is always hidden and called timeform. Thanks..

  2. #2
    2 Star Lounger
    Join Date
    Feb 2003
    Location
    Piscataway, New Jersey, USA
    Posts
    171
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: closing a form at shut down (Access 2000)

    If you have a main menu from which your app closes, say on an Exit command button, put the following code on its click event:

    DoCmd.Close acForm "yourformname" , acsaveprompt

    If you want to close ALL your forms etc., use this code:

    Public Function CloseObject(strContainerName As String, intContainerType As Integer)
    ' Close all open database objects. Called from frmMain

    Dim dbs As Database, ctr As Container
    Dim intX As Integer

    Set dbs = CurrentDb
    Set ctr = dbs.Containers(strContainerName)

    For intX = 0 To ctr.Documents.Count - 1 'Zero-based, but Count is 1-based
    DoCmd.Close intContainerType, ctr.Documents(intX).Name
    Next intX

    End Function

    Call it this way on your exit button's Click event:

    CloseObject "Tables", acTable
    CloseObject "Tables", acQuery
    CloseObject "Reports", acReport
    CloseObject "Scripts", acMacro
    CloseObject "Forms", acForm
    CloseObject "Modules", acModule

    Application.Quit

    This will close all your objects and then shut down Access.

  3. #3
    Lounger
    Join Date
    Mar 2003
    Location
    Gainesville, Florida, USA
    Posts
    26
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: closing a form at shut down (Access 2000)

    Hi,

    You can try using this code on your main form close event.

    DoCmd.Close acForm, "timeform"

Posting Permissions

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