Re: Deleting A FoxPro 2.5 Record From Specific Field
Originally posted by Seahawk0966
I have a FoxPro 2.5 Program that I need to add a function to Delete a Record..
Example: User presses D to delete that Record.
How do I do this?? I am a newbie and am having all kinds of trouble with the only!!!
There are several ways to code this, but it depends on what the user interface is at that point.
If it is in a BROWSE window, and they just wanted to type the letter 'D', you wouldn't want them to end up deleting that record. However, <Ctrl><T> will delete/recall a record (toggle the delete mark on or off).
If it is a command button on a screen, make the caption read \<Delete, which will underline the 'D', making it a shortcut key. Then you can have a function in the valid snippet of the command button something like delrec():
In the cleanup/procedures, add this code:
Actually, I omitted the PACK portion on purpose because that is really a maintenance function that is usually performed during down time.
Deleting the records, as you know, only marks them for deletion. In other words, flags them for removal using the PACK command.
While PACK works just fine, it is not condusive to a multi-user environment as the table needs to be open for exclusive use in order for the pack to execute.
What you would normally do (especailly in a multi-user environment) is issue the command:
SET DELETED ON
This command disallows deleted records from being displayed or accessed. They can then be packed at a later date.