Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set form values on the fly from table data 1

Status
Not open for further replies.
Sep 17, 2001
672
0
0
US
I have hundreds of textbox's that I want to set the values on the fly from a table. I tried the following be get and error saying, "ThisForm can only be used within a method":

SELECT citemjuliancount_final
SCAN
execscript("thisform.pgfInv.pagsummary.cntleft.cntwhites."+Columntxtname+".value='"+itemname+"'")
endscan

How can I dynamically set hundreds of textbox's from data in a table which has the textbox name and value stored in it?

Regards,

Rob
 
You don't set the values of controls, you set the controlsource of controls. To the field names, and you do so once, at design-time.

One - the easiest way to do so - is taking a form, having your dbf in its DataEnvironment, then drag single fields from the DataEnvironment to the form canvas (just organize your designer windows side by side), which creates controls already configured to display and maintain that field. When you drag a whole table you get a grid.

You can generally configure what you get in the menu: Tools->Options and the "Field mappings" tab of that options dialog.

Bye, Olaf.
 
Just two further thoughts in case you don't want two-way binding, eg just use the data to populate form control values, not let the controls write back data to the origin record:

1. You can just SELECT * FROM table INTO CURSOR crsForm READWRITE and bind to crsForm.
this still is two way but will not influence the origin table record. You can also make the controls readonly by NOT sepcifying the READWRITE keyword and instead just NOFILTER.

2. You can also predefine just one form property Form.oData and then SCATTER NAME THISFORM.oDATA ADDITIVE, which then creates all fields as properties of oDATA. Finally you bind controls to these properties via controlsource = "Thisform.oData.field1", etc.
This also again is twoway, this time to an object just temporary as a cursor also is. The advnatage is, you can pass on this object reference and so pass on a whole record in just one parameter. you may also finally GATHER that object somewhere else, eg have a template table and a differing destination table.

Bye, Olaf.
 
Thanks Olaf. I just added lctxtx controlsources to each.

Regards,

Rob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top