>I call the code below from the init method of my form.
>I pass the year.
>Depending on what the year is, I will open a class library for that year.
>
>For example, if the year is 2008, i will open cf2008.vcx.
>If the year is 2007, I will open cf2007.vcx.
>The class name and method is the same in both.
>cf2008.dfprintyearend.printreport
>cf2007.dfprintyearend.printreport
>
>When I initially launch the form, everything works.
>I open the correct library, create a reference to the class I need, and print the report for the year selected.
>
>When I close the form, I remove the reference to the yearly methods and release the library.
>thisform.RemoveObject('oyear')
>RELEASE CLASSLIB (thisform.ccflibrary)
>
>****************************************************************************
>THE PROBLEM
>When I close the form and launch it again, it doesn't work right.
>
>The year is 2008.
>thisform.ccflibrary is cf2008.vcx
>SET CLASSLIB TO (thisform.ccflibrary) ALIAS cf ADDITIVE works.
>
>BUT........
>thisform.AddObject('oyear','dfprintyearend')
>my reference is wrong
>
>oyear
>is pointing to cf2007.dfprintyearend.
>it needs to be pointing to cf2008.dfprintyearend
>
> What am I doing wrong?
>
>Deb
>
>************************************************************************************
>
>PARAMETERS pcyear, llinit
>
>LOCAL lcyear
>
>lcyear = m.pcyear
>
>IF !llinit
> * Remove the reference to the yearly methods.
> thisform.RemoveObject('oyear')
>
> * Release the library.
> RELEASE CLASSLIB (thisform.ccflibrary)
>ENDIF
>
>* Get the name of the yearly library, cf2008.vcx, .vct in c:\codemine\custom.
>thisform.ccflibrary = 'cf' + ALLTRIM(lcyear)
>
>* Open the library.
>SET CLASSLIB TO (thisform.ccflibrary) ALIAS cf ADDITIVE
>
>* Create a reference, oyear, to the year end print methods in dfprintyearend.
>thisform.AddObject('oyear','dfprintyearend')
>
>***********************************************************************************************************
Instead of AddObject() use NewObject() method. That way you have no need to SET CLASSLIB to anything:
PARAMETERS pcyear, llinit
LOCAL lcyear
lcyear = m.pcyear
IF !llinit
thisform.RemoveObject('oyear')
ENDIF
thisform.ccflibrary = 'cf' + ALLTRIM(lcyear)
thisform.NewObject('oyear','dfprintyearend', thisform.ccflibrary)
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.