Information générale
Catégorie:
Gestionnaire d'écran & Écrans
Titre:
Unable to switch database used by a form
How do we change database a form bound to at runtime?
I tried the following with tsBaseForm class (Tastrade sample app):
Load event:
x=this.dataenvironment.objects[1].database
this.dataenvironment.objects[1].database= strtran(x,'C:\','D:\')
Then I created MyForm based on tsBaseForm. I put Customer table in its dataenvironment and set DE's AutoOpenTables to .F.
I also dragged Customer table from DE to form so it created a grid with RecordSource property set to Customer.
When I run MyForm (from inside Tastrade app, of course) it went fine but when I back to form designer and change grid.column.ControlSource to customer.Name (previously empty) and run the form again an error appeared:
Data environment is already UNloaded.
Method: myform.dataenvironment.CloseTables
Line: 0
When I chose Ignore, another error came up but with blank message. When I click Ignore I threwn back to menu (the form never run)
It seems that problem occured if I change grid.column.ControlSource to something other than "(None)" (default).
What I'm looking for is a workaround other than open tables manually in form.Load
Thank you in advance
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement