I agree... IMO one should always keep method code as close as possible to the object(s) it references, to best maintain OO encapsulation. At runtime, it's often a sign of a design problem if you have to reference other objects.
>I think what he's trying to do is reference objects or properties from outside the class(object) itself, to make a refernce to itself "This" would be enough. What I find strange is the whole approach, the only reason I see for doing something like that is if you where adding objects at runtime, if not why not just hardcode it at design time?.
>
>Another approach would be to have the object tell the form who is his parent on the init method and store it in a property like this
>
>
>*!*Object.Init()
>ThisForm.CustomObjectParent = This.Parent
>
>
>When you need to make a reference
>
>With (Thisform.CustomObjectParent)
> .txtaddress.value=""
> .txtapt.value=""
> .txtcity.value=""
>EndWith
>
>
> >>Thanks for your answer.
>>>But maybe I don't understand you.
>>>
>>>Ex. ResetFields() in cntaddress (Address Class)
>>>Inside this method:
>>>
>>>WITH .... (what i need to put here so it works, no matter where the class is on the form)
>>> .txtaddress.value=""
>>> .txtapt.value=""
>>> .txtcity.value=""
>>> .
>>> .
>>> .
>>>ENDWITH
>>
>>You can use
>>
>>
>>WITH THIS.PARENT...(etc)
>>
>>
>>as needed.
>>
>>One neat trick: when you're in a method window, you can right-click and select "Object List...". If you select an object to reference from the list, a RELATIVE reference will be generated automatically.
Regards. Al
"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov
Neither a despot, nor a doormat, be
Every app wants to be a database app when it grows up