> > Hi again everyone.
> >
> > I am trying to build a calendar display that will give me a few options I can't find elsewhere (specifically, the ability to select a number of days at a time).
> >
> > While experimenting with how to achieve this, I have come across a wee problem.
> >
> > I have a form with a single checkbox on it and two command buttons.
> >
> > In the load method of the form, I declare an array...
> > Declare aCalendar(1,1)
> >
> > In the init method of the checkbox, I have the following code...
> > aCalendar(1,1) = This
> >
> > I have the following code in the click method of command1...
> > if aCalendar(1,1).enabled = .t.
> > aCalendar(1,1).enabled = .f.
> > else
> > aCalendar(1,1).enabled = .t.
> > endif
> >
> > All this works fine - clicking the command button changes the enabled proberty of the checkbox as I suspected it would and the display of the checkbox changes with each click to reflect it's enabled / disabled status.
> >
> > My problem is that, in the cliek method of command2, I have the code...
> > release all
> > thisform.release
> >
> > I expected the form to be released when I click this button, but it doesn't. If I run the form without the code aCalendar(1,1) = this, then the form will release as usual. Putting the above code back recreates the problem.
> >
> > What have I missed please ?
> >
> > Thanks.
> >
> > Deane
>
> Hi Deane
>
> You cannot expect to have this code in the form load "Declare aCalendar(1,1)" and expect it to be in scope in the rest of the form. I have just tried what you suggested and the array goes out of scope. So you must be declaring it somewhere else before the form starts so that it is in scope.
>
>
> Therefore this line will NOT work:
>
> >In the init method of the checkbox, I have the following code...
> > aCalendar(1,1) = This
>
> as aCalendar(1,1) is out of scope and you will get a "variable not found" error. I suspect you are creating this variable somewhere else which is why it is in scope. The statement in the LOAD of the form has nothing to do with it.
>
> Other than that, looks like a case of Dangling Object References.
>
> Try this code in the click method of command2:
> aCalendar[1,1] = .NULL.
> RELEASE aCalendar
> ThisForm.release
Hi Bernard.
Thanks again !! - issuing aCalendar(1,1) = .null. does the trick.
I was expecting Release All to achieve the same result - obviousely not.
Thanks
Deane