Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Set form values on the fly from table data

Set form values on the fly from table data

Set form values on the fly from table data

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

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



RE: Set form values on the fly from table data

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.

RE: Set form values on the fly from table data

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.

RE: Set form values on the fly from table data

Thanks Olaf. I just added lctxtx controlsources to each.



Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close