>I have this object with many textbox. All textbox are bound to a field. Ex:ControlSource=”MyAlias.MyField1” but in some case I need to change the alias to “IsAlias”.
>
>If I change the alias in the init() of the object I get a error because the alias “MyAlias” do not exist.
>Where is the best place to control the alias of controlsource?
>
>Passable solution:
>Having a subclass of the object with all control source change to the alias “IsAlias”.
>Coding the controlsource from the init() of the object for the right alias with a parameter.
>Using a cursor object in the form and control it from the loadevent() of the form.
>
>Any one can help me with this one!
Jean,
If you change the alias in init then it should be available (if you're setting it to IsAlias.MyField then IsAlias must be available). Before init form.load or form.de would open it. If you have situation where availability is postponed then create a method that would do it. Method :
-Checks availablity of alias.
-If exists loops through controls and sets controlsource to :
stuff(Controlsource,1,at(".",Controlsource)-1,"NewAlias")
(You might want to check if controlsource is in MyTable.MyField format)
-Refreshes control
Or alternatively if you're using DE :
-In DE change cursorsource and database of the cursor using "myAlias"
Cetin