Results 1 to 4 of 4
  1. #1
    2 Star Lounger
    Join Date
    Nov 2002
    Posts
    160
    Thanks
    0
    Thanked 0 Times in 0 Posts

    close active form (2k)

    i have main form i want if that ( main) is active my db closed after 1 min .
    but if i open another forms the db not close . only main is activ.
    i put that code
    Private Sub Form_Timer()
    DoCmd.Close acForm, Me.Name
    End Sub
    and put the timer 60000 but i found all the db closed alothough i open another forms .
    thanks advanced
    ashraf

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

    Re: close active form (2k)

    If I understand you correctly, you want the database to remain open if other forms than the main form are open. However, your code doesn't test for this. Also, you want to close the database; for this you can use CloseCurrentDatabase (database closes, Access remains active) or Quit (Access quits).

    The Forms collection contains all open forms (subforms are not counted). If *only* the main form is open, the Forms collection will have just 1 element. If more forms are open, it will have more elements. So you can test on Forms.Count > 1:

    Private Sub Form_Timer()
    If Forms.Count = 1 Then
    Quit ' or CloseCurrentDatabase
    End If
    End Sub

  3. #3
    2 Star Lounger
    Join Date
    Nov 2002
    Posts
    160
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: close active form (2k)

    thank u hans
    i replaced my code with ur code in the main form but not work .
    ashraf

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

    Re: close active form (2k)

    How does it "not work"? Does the database not close when other forms are open, or not close when other forms are open, or are you getting an error message?
    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
  •