My program works with access files *.mdb. Everything is working, but when i push the close button the program close itself, but it remains in memory (i can see this when i press Ctr+Alt+Del). My program is working on WinXP. The close button's code is Unload Me. What can be the problem?
I'm not using any activex neither access over a network. The database files are access files (mdb). I think that the problem comes from there somewhere, a connection to that database is not closed, but the forms that work with the database are created automatic by the VB6 wizzard.
Do forms reference each other? You could have a chain of circular references.....
TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!) 2008, 2009 In theory, there is no difference between theory and paractice; in practice there is.
* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first
I have a main form within i call several other forms. I'm using variabiles from one form in another form. I don't know if that can generate circular references.
'Private sub Query_Unload(....)
dim frmX as form
For each frmX in Forms
If frmX.Hwnd<> Me.Hwnd then
Unload frmX
end if
Next
dim sMessage as string
If Forms.Count>1 then
For each frmX in Forms
If frmX.Hwnd<> Me.Hwnd then
sMessage =sMessage & frmX.Name & " "
end if
Next
Msgbox "Something made " & sMessage & " not closing correctly"
end if
'End Sub
...at present time, using mainly Net 4.0, Vs 2010
Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
Originally posted by Illuvatan
Unload me isn't closing the whole app..
Add to your Exit Button the Code:
Exit() (or something like that) and your program will close without you having to think about any forms that may be still open
greetings UNI
you mean END ?
it's not preferable to call END
from msdn :
Note The End statement stops code execution abruptly, without invoking the Unload, QueryUnload, or Terminate event, or any other Visual Basic code. Code you have placed in the Unload, QueryUnload, and Terminate events of forms and class modules is not executed. Objects created from class modules are destroyed, files opened using the Open statement are closed, and memory used by your program is freed. Object references held by other programs are invalidated.
1) The Exit commands didn't help. I think that this command only interrupts a for, if, or sub execution without doing anythig else.
2) I'm not quite sure where to put that code. I've put it in the exit sub of the main form. Did i do good?
Putting the code in the exit sub didn't display any messages but also stopped from closing my application. I guess smthin' wrong.
3) An the last but not least and also THE SOLUTION were these three "magic" letters: END . I've commented the Unload Me and the code from Cimperiali and writted the END statement. My exit sub looks like this now:
Private Sub Iesire_Click()
End
End Sub
So i think that the problem is solved and i thank to all who helped me.
as hspc stated, End is to avoid: it terminates abruptly your code.
Obejcts that need to enter the Terminate_event (or even the
Unload_ procedure) to make cleanup, will not enter that code,
thus nothing is correctly cleaned....Better should be to step inside
code and try to understand what is going wrong (there is always
a "why" if a program does not really stop...). You may think you
have solved, now, and maybe it will work for you. But maybe a
bug will come out soon....
...at present time, using mainly Net 4.0, Vs 2010
Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
Yes - don't use 'End', especially when working with Access databases.....you could corrupt your database quite easily...
Unloading each of the forms in the forms collection is the correct approach, use the code that Cimperiali has provided - it will work if in the right place & called correctly!
I guess there is a good reason why my program won't end well when i call the Unload command, but i can't figure it out why...all my forms have the unload command yet the program isn't ending.
Cimperiali gave me a code but i don't know where to put it. Could u give me a little more details, a little project where the code is implementing and working pls?
Bookmarks