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!

How to create window to read records from table

Status
Not open for further replies.

zalewski66

Programmer
Jul 29, 2002
4
0
0
US
I want to create a screen where it will read the values from a table with one record holding values that will be placed into public variables. I want to open this window to the user and allow them to make edits to the values, then set the new value to the public variable and update the table. Is there a place I can look for some good examples. It seems like its very complicated process.
 
It depends on your specific requirements but simply put, say your table has a structure of:

firstname C(20)
lastname C(25)
dob D( 8)

You could start with the following data entry screen:
Code:
*.........  MyProg.PRG  ................
SCATTER MEMVAR 
@ 1, 1 SAY '   First Name: ' GET firstname
@ 2, 1 SAY '    Last Name: ' GET lastname
@ 3, 1 SAY 'Date of Birth: ' GET dob
READ
GATHER MEMVAR
RETURN

Dave S.
[cheers]
 
Dave,
How then so I get the values to be stored in the table and are those public variables ?
 
SCATTER MEMVAR creates variables corresponding to the field names of the table. GATHER MEMVAR replaces the current fields in the currently selected table with the values stored in the variables of the same name, which are modified by the user when the above @...SAY/GET and READ are implemented.
They are not public when SCATTERed, but you can create public variables by issuing a PUBLIC statement at the beginning of the program, then the rest of the code after that:

Code:
*.........  MyProg.PRG  ................
PUBLIC firstname, lastname, dob 

SCATTER MEMVAR 
@ 1, 1 SAY '   First Name: ' GET firstname
@ 2, 1 SAY '    Last Name: ' GET lastname
@ 3, 1 SAY 'Date of Birth: ' GET dob
READ
GATHER MEMVAR
RETURN

Or, if you aren't looking for even that amount of program control:

USE somedb
BROWSE

They can edit in the browse window too, and the changes will be saved when they press <Ctrl><W>.


Dave S.
[cheers]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top