Seems to work for me. Perhaps there is code elsewhere (e.g. in
frmSecurity) that is having an effect? Here's my test, stripped down
to the essentials of what your posted:
'----------------------------------
'<Code in class module named Class1>
Option Explicit
Private Sub Class_Initialize()
If colScrollArea Is Nothing Then
Stop ' hard breakpoint
' Next line only fires once (correct)
Call populateScrollAreaCollection
End If
End Sub
Private Sub Class_Terminate()
Set colScrollArea = Nothing
End Sub
'</Code in class module named Class1>
'----------------------------------
'<Code in a standard module>
Option Explicit
Public colScrollArea As Collection
Sub populateScrollAreaCollection()
Set colScrollArea = New Collection
End Sub
Sub Test()
Dim c1 As Class1
Dim c2 As Class1
Set c1 = New Class1
Set c2 = New Class1
End Sub
'</Code in a standard module>
'----------------------------------
--
Joe <(E-Mail Removed)> wrote in message news:<1B7DD63E-F2D7-4BF6-A0A6-(E-Mail Removed)>...
> Sorry I forgot the code (Please see below). The first time that I call this class, I populate colScrollArea. The second time that I call this class, it, for some reason that I don't see, destroys colScrollArea. Does anyone have any ideas?
>
> I am using XL 2002.
>
> TIA,
>
> Joe
>
> Code:
>
>
> Private Sub Class_Initialize()
> Set m_f = New frmSecurity
> If colScrollArea Is Nothing Then
> Call populateScrollAreaCollection
> End If
> End Sub
>
> Private Sub Class_Terminate()
> Unload m_f
> Set colScrollArea = Nothing
> Set m_f = Nothing
> End Sub
>
> populateScrollAreaCollection is a public sub in a module and has the following code:
>
> Public Sub populateScrollAreaCollection()
> Set colScrollArea = New Collection
> With colScrollArea
> .Add WKS_SA_MAIN, WKS_MAIN
> .Add WKS_SA_ECHO, WKS_ECHO
> .Add WKS_SA_CATH, WKS_CATH
> .Add WKS_SA_NUCLEAR, WKS_NUCLEAR
> .Add WKS_SA_OTHER, WKS_OTHER
> .Add WKS_SA_PACS, WKS_PACS
> .Add WKS_SA_SYSTEM, WKS_SYSTEM
> .Add WKS_SA_REVIEW, WKS_REVIEW
> .Add WKS_SA_NETWORK, WKS_NETWORK
> .Add WKS_SA_RESULTS, WKS_RESULTS
> End With
> End Sub
>
> where colScrollArea is declared as
>
> Public colScrollArea As Collection
|