General information
Category:
Forms & Form designer
Title:
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
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only