How do I close form if not used?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • malcolmk
    New Member
    • Sep 2010
    • 79

    #16
    use the DoCmd.Close acForm, "formname"
    in the "active" event on the main form so that after selecting your option on form fselct when the next form opens insert the command into that forms "active" event.
    so eg. form1 make aselection and call form2, when form2 opens its "active" event closes form1.

    Comment

    • FishVal
      Recognized Expert Specialist
      • Jun 2007
      • 2656

      #17
      Form couldn't be closed while handling Deactivate event, but it could be closed while handling Timer event.

      Code:
      Private Sub Form_Deactivate()
          Me.TimerInterval = 1
      End Sub
      
      Private Sub Form_Timer()
          DoCmd.Close acForm, Me.Name
      End Sub

      Comment

      • OldBirdman
        Contributor
        • Mar 2007
        • 675

        #18
        Apparently this does work. Thank you. Closing an already closed form doesn't seem to cause an error, so other causes of activate not resulting from return from fSelect aren't a problem.
        I say 'Apparently' because testing the Activate condition is difficult. Any attempt to use the debugging tools cause activate/deactivate to fire as the focus moves between the program forms and the debugger.

        Comment

        Working...