Determine if object has been instantiated

  • Thread starter Thread starter Thomas Kroljic
  • Start date Start date
T

Thomas Kroljic

All,
Is there a way in Access (VBA) to check with code if an object (not a
table, report, query, or form) has been instantiated? I'm trying to check to
see if a certain datatype as been created or exist. I know that in Visual
Basic they have code as follows but this doesn't seem to work in VBA:

if (not objectname is nothing) then

endif



Thank you,
Thomas Kroljic
 
Thomas said:
All,
Is there a way in Access (VBA) to check with code if an object (not a
table, report, query, or form) has been instantiated? I'm trying to check to
see if a certain datatype as been created or exist. I know that in Visual
Basic they have code as follows but this doesn't seem to work in VBA:

if (not objectname is nothing) then

endif


That works in VBA too. Maybe you are using the wrong thing
for ObjectName?? It should be the name of a variable that
was assigned a new or existing instance of the object.

Set myclass = New yourclassname
If myclass Is Nothing Then
' myclass does not exists
Else
' myclass exists
End If
 
Thomas Kroljic wrote in message said:
All,
Is there a way in Access (VBA) to check with code if an object (not a
table, report, query, or form) has been instantiated? I'm trying to check to
see if a certain datatype as been created or exist. I know that in Visual
Basic they have code as follows but this doesn't seem to work in VBA:

if (not objectname is nothing) then

endif



Thank you,
Thomas Kroljic

Be aware of implicit instantiations

Check out the different methods of binding from here
http://www.vbcity.com/forums/faq.asp?fid=6&cat=System

If you declare as in method 3 (with the New keyword), every reference
to the object will cause it to be reinstantiated - also the test you
posted;-)
 
Marsh,
Thanks for the quick response. I have to admit, I wasn't paying attention
to what the error message I was receiving really meant. After reading you
message, I went back into my VBA code and substituted another object in the
syntax you sent and it worked fine. Upon the realization that yes you could
check within VBA if an object existed, it hit me as to what the error
message that was being displayed really meant.
Thanks for opening my eyes and mind to the real problem.

I corrected the problem and have more forward with my coding. Thanks.
 
RoyVidar,
Thanks for the info. With the help from you and others on this forum, I
discovered my problem and resolved the issue.

Thanks,
Thomas j. Kroljic
 
Back
Top