Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Add Tables
Message
From
13/03/1998 06:17:36
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Title:
Miscellaneous
Thread ID:
00084113
Message ID:
00084381
Views:
39
Snip..
>>Cetin
>Hello Again,
>
> As the battle rages on, I seem to be getting nowhere...
>
>I'm encountering a host of problems with forms. When run as a normal .scx from the project manager myform returns: "The data source for this object must be variable reference"
>
>use mytable in 0 alias dummy
>thisform.Text1.controlsource = dummy.description <-- This line causes the error
>
>If I comment out this line the form .scx runs normally.
>
>The following code causes another error when I attempt to use a class with a DE containing cursor1 and the initial selected alias set to cursor1.
>
>SET CLASSLIB TO vdolib.vcx ADDITIVE
>oPlayForm = CREATEOBJECT('test')
>oPlayForm.dataenvironment.addobject("cursor2","cursor") <-- Causes unknown member error ie: there is no DE contained in this instance
>
>BTW - This error is the same with nothing in the data environment prior to saving as class
>
>I guess I don't understand this error. If I create a form visually with a DE and control sources set(like the wizard), why does it complain it is an unknown member when this form is saved as a class, then created using CREATEOBJECT()? Is this not essentially the same object whether run as .scx or an object created in runtime code? Do I need to oPlayForm.addobject("dataenvironment", "dataenvironment")? I attempted this and got a message saying the object type is invalid for the container. Does this mean the form that was saved as a class does not qualify to contain a DE?
>
>The score is now, VFP - 1
> ERIC - 0
>
>Eric K.
Eric,
Forget about "save as class". Sorry having your time for that. Try the following with a wizard form.
-To a "temp" dir copy all the files (unnecessary qpr etc exists I know) in home()+"samples\data" (testdata.dbc and tables).
-Set default to your "temp" dir
-Create a wizard form using "customer.dbf"
-Add 4 command buttons to form
-You'll change the wizard button cmdExit also
-Code for buttons are following.
Try this. These could be extended to custom methods as needed.
* Wizard buttons
* cmdExit.click
thisform.lockscreen = .t.
thisform.dataenvironment.closetables
with thisform.dataenvironment.cursor1
	.database = curdir()+"testdata.dbc"
	.cursorsource = "customer"
endwith
thisform.dataenvironment.opentables
open database curdir()+"testdata.dbc"	
nTableCnt = adbobject(aTables,"Table")
for ix = 1 to nTableCnt
	if aTables[ix] = left(sys(2015),4)
		drop table (aTables[ix])
	endif
endfor
thisform.lockscreen = .f.
dodefault()

* Change table
* cmdButtonChange.click
thisform.lockscreen = .t.
thisform.dataenvironment.closetables
with thisform.dataenvironment.cursor1
	.database = home()+"samples\data\testdata.dbc"
	.cursorsource = "customer"
	.order = "Company"
endwith
thisform.dataenvironment.opentables
thisform.refresh
thisform.lockscreen = .f.

* Back to original
* cmdButtonBack.click
thisform.lockscreen = .t.
thisform.dataenvironment.closetables
with thisform.dataenvironment.cursor1
	.database = curdir()+"testdata.dbc"
	.cursorsource = "customer"
	.order = "Country"
endwith
thisform.dataenvironment.opentables
thisform.refresh
thisform.lockscreen = .f.

* On the fly table
* cmdButtonOnTheFly.click
_screen.comment = sys(2015)
cCompanies = left(customer.company,1)
thisform.lockscreen = .t.
select * from (thisform.dataenvironment.cursor1.alias) ;
	where Company = cCompanies  ;
	into table (_screen.comment)
index on company tag company
use
open database curdir()+"testdata.dbc"	
add table (_screen.comment)
thisform.dataenvironment.closetables
with thisform.dataenvironment.cursor1
	.database = curdir()+"testdata.dbc"
	.cursorsource = _screen.comment
	.order = "company"
endwith
thisform.dataenvironment.opentables
thisform.refresh
thisform.lockscreen = .F.

*Change controlsource on the fly
*cmdButtonCSource.click
if ThisForm.COMPANY1.controlsource = "customer.company"
	ThisForm.COMPANY1.controlsource = "customer.contact"
	ThisForm.CONTACT1.controlsource = "customer.company"
else
	ThisForm.COMPANY1.controlsource = "customer.company"
	ThisForm.CONTACT1.controlsource = "customer.contact"
endif
Cetin
Ç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
Reply
Map
View

Click here to load this message in the networking platform