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:
00454766
Views:
35
>VFP 6.0
>
>I have the VFP settings in Options...
>-Locking and buffering
>-Multiple record locks
>-Buffering: Record (Optimistic)
>
>I believe I did set that, and then this morning, I checked it and it was changed? Anyway, I clicked 'Set as Default'.
>
>Now, I like to know what is the best way to take advantage of the optimistic record buffering? This is what I have coded in the 'Add' button (Click Event):

The settings in your VFP Options are not necessarily reflected in your forms. The cursors in your forms will default to the form setting or you can set them for each cursor in the data environment.

>SELECT person
>LOCATE FOR DELETED()
>IF NOT EOF()
> REPLACE id WITH ''
> RECALL
> SCATTER
>ELSE
> APPEND BLANK IN person
>ENDIF
>ThisForm.REFRESH

If you are using a formerly deleted record, you need to remove any existing data from the fields right before or after recalling the record -- see Field() function where you can loop through the fields for this. I would not blank the PK field. You should use your PK generator to replace this value with a new PK if you do not want to reuse the old PK.

Scatter is not needed.

For buffering, you need to learn the following functions: TableUpdate, TableRevert, GetNextModified, GetFldState, CurVal, OldVal.

>and this isn't correct, but this is how far I got. I want to be able to have the user input the data on the form (with a grid) and then click 'Save' (then save the record) or 'Delete' (clear the form or actually delete a record). FWIW, this is what I have in the 'Delete' button (Click Event):
>
>nAnswer = MessageBox('Do you want to delete this record?',4)
>IF nAnswer = 6
> DELETE
> SKIP -1
> IF BOF()
> LOCATE
> ELSE
> SKIP
> IF EOF()
> SKIP -1
> ENDIF
> ENDIF
>ENDIF
>ThisForm.REFRESH
>
>and I have not gotten the 'Edit' button yet (and the whole form is still enabled, as of now)... One thing I must inform now is that there is a Primary key in the table, so it must be uniqueness (otherwise error violation)...
>
>Chuck
Mark McCasland
Midlothian, TX USA
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform