Solved

While unloading a form using set frm = nothing the form reloads any ideas why?

Posted on 2008-06-09
5
329 Views
Last Modified: 2010-04-21
Hi

I have several routines to unload an application. The main window is called frm_toolbar. All unloaded fine until I added a timer, I've added code to close the timer before unloading the form and this appears to work ok. But the main form is not unloading, it appears to close but is still running in the background.

If I add set frm_toolbar = nothing the form closes then reloads, if I then clock close it closes and unloads fine. Here is the code I use to initiate the close routines

If unload_main = True Then
Cancel = 0
Else
Cancel = 1
End If

Any ideas appreciated, this is a tricky one.
this is the unload main reoutine. it closes a couple of folders, exits the loop via a exitloopas boolean variable
 
Source = frm_toolbar.Label3.Caption
 
'write the current preset calibration value to the ini file
 
preset_cal = frm_toolbar.txtprecals.text
 
Call WritePrivateProfileString("Calibration", "Pre_set", preset_cal, filename)
Call WritePrivateProfileString("Calibration", "source", Source, filename)
 
'delete the temporary file in the application data folder
 
If IspathExist(temp_folder) Then
 
Dim fso As New FileSystemObject
Set fso = CreateObject("Scripting.FileSystemObject")
fso.GetFolder (temp_folder)
fso.DeleteFolder (temp_folder), False
 
'Kill temp_folder
End If
 
'delete the temporary file in the application data folder
 
If IspathExist(temp_folder2) Then
 
Set fso = CreateObject("Scripting.FileSystemObject")
fso.GetFolder (temp_folder2)
fso.DeleteFolder (temp_folder2), False
 
End If
 
 'close the open version of image pro
 
AppActivate image_pro
  Wait 1
SendKeys "%{F4}", True
Wait 0.1
 
    exitloop = True
    frm_toolbar.Timer1.Interval = 0
    frm_toolbar.Timer1.Enabled = False
 
 
 'ensure that all the form have been unloaded
 
 Dim i As Integer
   For i = Forms.count - 1 To 0 Step -1
      Unload Forms(i)
      Set Forms(i) = Nothing
   Next
   
Exit Function

Open in new window

0
Comment
Question by:eneate
5 Comments
 
LVL 21

Expert Comment

by:oleggold
ID: 21745681
0
 

Author Comment

by:eneate
ID: 21745921
thanks, but I've tried all of those but I still can't get the application to copmpletly unload.
0
 
LVL 10

Accepted Solution

by:
cool12399 earned 250 total points
ID: 21746981
Are you setting your timer to .enabled=false?

Whatever your timer code, you need to do something like timer1.enabled=false, before closing the form, otherwise the timer will automatically 'reopen' the form.

Also, make sure you aren't doing anything strange in your query_unload event in your frm_toolbar (i.e., only unloading if an 'x' is clicked on, etc).
0
 
LVL 13

Assisted Solution

by:game-master
game-master earned 250 total points
ID: 21748087


good morning...

if you really wanted to close
the application on your timer,
i would rather suggest you to use
the "END" on your timer...

in this case, the application will be closed..


game-master
0
 

Author Closing Comment

by:eneate
ID: 31465503
Thanks for the feedback. I called a close to an external shell app from within the close routine, this when combined with the timer was the cause of the problem. I've put it into a separate boolean variable and it now all unloads correctly.
Thanks
0

Featured Post

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Vb.net 2008 2 59
change vba from autofit to 13.5 width? 4 29
Crystal reports - Formula Field code need assistance with code 17 73
Hide vba in gp 7 94
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

770 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