[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Problems getting app to stop running when closed.

Posted on 2000-04-20
6
Medium Priority
?
189 Views
Last Modified: 2012-05-04
What is the proper way to code for the app being closed?  When I close my app, it keeps running in the background and I don't know how to get it to stop.  I'm sure this is a simple question, I just don't have any clue.
0
Comment
Question by:jasonboetcher
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 28

Expert Comment

by:AzraSound
ID: 2734993
it depends on what objects you may be creating but as for closing all the forms.  in your main form use this:

Private Sub Form_Unload()
   Dim frm As Form
   For Each frm in Forms
     If frm.hWnd <> Me.hWnd Then
        Unload frm
     End If
   Next
   Unload Me
End Sub
0
 

Expert Comment

by:moterk
ID: 2734999
Does your app have any forms?  Or just a sub main?  To quit a program with just a sub main, use the END command.  If you have forms unload your startup form and in its unload event use the END command.  Is is also best to set all objects you have created to nothing.
0
 
LVL 2

Expert Comment

by:Sage020999
ID: 2735000
Are you using class modules or databases?  Often times that I have seen that problem is because forms, class, or databases aren't being closed and set to nothing.  Here closing code.


Sub FileExit()

  Dim LogRS As DAO.Recordset
  Dim ctr As Integer
  Dim DB As DAO.Database
  Dim strSQL As String
  Dim lngRC As Long
  Dim lngRC2 As Long
 
  On Error Resume Next



   'Close all recordsets and databases
    Set LogRS = Nothing
    Set DB = Nothing
    Set frmMain.DTDs = Nothing
    Set frmMain.InvcDs = Nothing
    Set frmMain.InvDs = Nothing
 
    For ctr = 0 To Forms.Count - 1
      If Forms(ctr).Name <> "frmMain" Then
        Unload Forms(ctr)
      End If
    Next ctr
    'Now unload frmMain
    For ctr = 0 To Forms.Count - 1
        Unload Forms(ctr)
    Next ctrEnd

End Sub
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 1

Accepted Solution

by:
derekcmartin earned 100 total points
ID: 2735159
And if all else fails, use

private sub form1_unload()
     end
end sub
0
 

Author Comment

by:jasonboetcher
ID: 2735317
I have a main form and many sub forms.  I was setting each of the forms to nothing as they were being unloaded.  The piece I was missing was the End command.
0
 
LVL 1

Expert Comment

by:derekcmartin
ID: 2735617
Thanks!  8o)
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question