Wrox Programmer Forums
|
BOOK: Access 2003 VBA Programmer's Reference
This is the forum to discuss the Wrox book Access 2003 VBA Programmer's Reference by Patricia Cardoza, Teresa Hennig, Graham Seach, Armen Stein; ISBN: 9780764559037
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Access 2003 VBA Programmer's Reference section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 30th, 2004, 03:30 AM
Authorized User
 
Join Date: May 2004
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default using DAO

Hello again,
I have another question concerning about the delete and set to nothing for a variable at the end of its life.
For example, in your book (chapter 6 using DAO to Access Data page 139, line 6)
varPKey = GetPrimaryKey(tdf)
why don’t you set varPKey = Nothing like the other variables (idx, tdf, dbs)


 
Old July 1st, 2004, 02:42 PM
Authorized User
 
Join Date: Jun 2004
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I don't have a copy of this book (yet), but (from my experience) ...

Object Variables:
Must be defined using the Dim command
    Dim dbs as Database
Must be defined using the Set command
    Set dbs=currentdb()
Object variables should be set to Nothing to free up all memory and system resources associated with the object
    Set dbs=Nothing

Non-Object Variables
Must be defined using the Dim command
    Dim varPKey as Variant
Must be defined using the Dim command
    varPKey = GetPrimaryKey(tdf)
Non-object variables memory issues are based on the how the variable was defined (i.e., local, private or public in scope)

In you post it appears that varPKey is a non-object variable of type variant. If that variable was defined within a Sub procedure, the value of varPKey will be lost once the Sub procedure ends.

Hope this helps ...

Terry Waltz
 
Old July 22nd, 2004, 08:46 AM
Authorized User
 
Join Date: Jul 2004
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default

vubinhsg,

As Terry correctly suggests, you only explicitly destroy object variables. In the case you cite, varPKey is not an object variable because GetPrimaryKey does not return an object - it returns a string in a variant datatype.

Regards,
Graham R Seach
Microsoft Access MVP

Graham R Seach
Microsoft Access MVP





Similar Threads
Thread Thread Starter Forum Replies Last Post
ADO or DAO knowledge76 Access VBA 3 October 12th, 2015 04:26 PM
DAO yanis97 Java Databases 0 September 6th, 2006 10:37 AM
ADO vs DAO perrymans BOOK: Expert One-on-One Access Application Development 0 October 24th, 2004 11:36 PM
PLEASE HELP, VB6 and DAO mszewczyk VB Databases Basics 6 May 6th, 2004 10:14 AM
DAO / ADO? merguvan Access VBA 8 January 18th, 2004 07:39 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.