Computer Learning Zone CLZ Access Excel Word Windows

Somewhere, something incredible is waiting to be known.

-Carl Sagan
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Microsoft Access 320    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 

 Chris 
      
16 years ago
AC320.2 TS 4:32 - I noticed that you create the object db and rs and then you destroy it (Clean it up) backward - i.e. set rs to nothing then the same with db. I assume by this that there is a particular order of creation and tidying. It this assumption correct?


Reply from Richard Rost:

This just goes back to my C/C++ programming days.

In C/C++ you have to remember to manually clean up any variable pointers and other objects yourself, and in the correct order, otherwise you end up with craziness in your programs. Things called NULL POINTERS (pointers to nothing) can wreck havoc in your programs.

Think of object variables like plastic containers. If you declare a variable to a database object, that's a big container. If you then declare a variable to a recordset, then that's a container INSIDE a bigger container. It's dependent on the database object to exist.

Well, if you destroy the database pointer first, then the recordset pointer really doesn't reference anything useful since it's parent is gone. It's a small container floating out in space with nothing holding on to it. :)

HOWEVER, none of this really matters in VB or VBA because Visual Basic is very good at cleaning up after you. The guys who created VB realized that most people using it aren't professional programmers, so they made it so the language cleans up most things like this for you... unlike in C/C++ where you have to do all of the housekeeping yourself... it's a trade-off for more power to control variables right down to their memory address.

Anyhow... to answer your question, it's good FORM to clean up dependent variables before their parents, but it's not 100% necessary in VB. In fact, by default, whenever you exit a sub or function, VB will clean up that memory for you... but don't get used to it. Try to remember to clean up your variables on your own. It's a good habit to be in if you do ever decide to move on to "grown up" programming languages. :)

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Microsoft Access 320.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/6/2026 6:06:58 PM. PLT: 1s