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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

populating existing data to text controls in a form

Status
Not open for further replies.

namax

Technical User
May 22, 2011
19
PG
I have an existing table with data and wish to update some fields with new values.So I created a form and add text controls respective to each fields.I want the existing values respective to each fields to populate each controls that are uniquely identified by their 'id'.(ie the id is the unique field).That is,for instance,if I enter "0001" into the id text field then all the text controls like "name","age","date of birth" on the form should be populated with the data specific to the id "0001" and so forth.

Will anybody just give me a tip on what commands or way I could follow to achieve the result to this problem that is quite new to me.

Please let me know if I am not precise with my query.

Thankyou in advance.
 
This is really basic functionality. Have you tried anything so far?

Here are the highlights:

* Bind all of the controls to fields in the table EXCEPT the ID field
* In the unbound ID control, add code in the Valid method to SEEK() the value entered in the ID control
* If a record is found, simply issue Thisform.Refresh() and there you are

The complexity can escalate and can it can do so rapidly and dramatically.

If you need to understand fundamentals, I'd recommend:

 
put your table ino the data environment and have it open beside an empty form. Then drag all the fields you want to edit from the dataenviornment table to the form and controls that show the fields are automatically created.

Don't do that with the ID field though, as you want to enter an id. Put a textbox to the form, set its value to 0 and leave it's controlsource empty. Then do as dan suggests. In it's valid event put in a SEEK This.value (set order must be set to the index on id then) or LOCATE FOR id = this.value and a Thisform.Refresh().

That's about it already.

Bye, Olaf.
 
Will anybody just give me a tip on what commands or way I could follow to achieve the result to this problem that is quite new to me.

For answers to basic questions like these I generally recommend that you spend some time going through the various associated free on-line VFP tutorial videos at:

You will find a LOT of basic information there to help you learn VFP.

Good Luck,
JRB-Bldr
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top