Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to 'Add' a record?
Message
 
To
18/12/2000 13:57:44
Chuck Tripi
University of Wisconsin - Milwaukee
Milwaukee, Wisconsin, United States
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00454759
Message ID:
00454786
Views:
25
Chuck,

This is always a problem in deciding whether to use the data buffering of VFP or another means. When using the data buffering, you rely on VFP to control record writes. The programming you have looks like you want to control the writes.

Here is one way that I have done it...

First, create a memory varuable for each data element and assign the form controls to the memory variables. You can do this in the forms init method.

Second, also in the init, load the memory variables with the contents of the data record. (You also have the option of doing this in a separate procedure which is a better place if you plan to use them over and over.)

Normally, set all the control boxes enable to .f.

In the click event of an EDIT control button, enable all the data spaces. and turn on a save and a revert button.

In the click event of the revert button, just reload all the memory var's from the current record, and disable all the controls.

In the click event of the save button, do your check for the correct key, and then do the options you want from there. You may say that this record exists and ask if they want it updated. Or you may ask for a new key value, or you may do your replace things. If you are adding a new record, this is the place to put your append blank and then replace. On exit, disable all the controls again.

Another option is to check for a duplicate key in the valid method of the control.

HTH (Go Packers)

Ron.
Ron Seidl
Independent Developer
VFP

"I'm playing in life's theater in anticipation of a great cast party!"
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform