Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ADDOBJECT
Message
From
15/09/1999 12:18:10
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
15/09/1999 11:55:53
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00264974
Message ID:
00265037
Views:
17
>John,
>
>I am trying to add tables to the data environment of a form. This needs to be done dynamically since the number of tables and their names are customizable by the user. I really don't have a problem with AddObject creating a cursor as much as the rest of the code to attach the tables to the data environment. This is my Code which will not work.
>
>Dime gsMyCursor(5)
>For myx = x To ALEN(gnTables)
> With ThisForm.DataEnvironment
> .AddObject(gsMyCursor(myx), "cursor")
> .gsMyCursor(myx).DataBase = "c:\MyFolder\Apps\Church Books\churchdata.dbc"
> .gsMyCursor(myx).CursorSource = gaTables(myx)
> .CloseTables()
> .OpenTables()
> EndWith
>Next myx


Where is the name of object ? gsMyCursor elements seem to be all .f.

dimension myCursors[5]
myCursors[1] = "table1"
myCursors[2] = "table2"
myCursors[3] = "table3"
myCursors[4] = "table4"
myCursors[5] = "table5"
with thisform.dataenvironment
.CloseTables
for ix = 1 to alen(myCursors)
.AddObject("Cursor"+padl(ix,2,"0"),"Cursor")
with eval("Cursor"+padl(ix,2,"0"))
.Database = "c:\MyFolder\Apps\Church Books\churchdata.dbc"
.Cursorsource = myCursors[ix]
endwith
endfor
.OpenTables
endwith

* But there is an easier way if it's a private data session
* Load event
dimension myCursors[5]
myCursors[1] = "table1"
myCursors[2] = "table2"
myCursors[3] = "table3"
myCursors[4] = "table4"
myCursors[5] = "table5"
for ix = 1 to alen(myCursors)
use (myCursors[ix]) in 0
endforCetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform