>>Greetings,
>>
>>I have a simple grid tied to a table and a command button to delete the current record. If I just mark the record as DELETEd, the grid shows the record as marked. However, if I issue a PACK, the grid immediately disappears. It does not matter whether I am removing the record or keeping others.
>>
>>If I use an ADD button on the screen, a record is added to the table, but the grid will still not redisplay unless I restart the application. Any ideas?
>>
>>Thanks!
>>
>>Michael Reynolds
>
>Hi Michael,
>PACK is a maintenance command and you wouldn't normally use it in a user environment. When it is issued it closes down the link to the database temporarily - so the grid looses it's bindings to the data.
>To hide deleted records use SET DELETED ON and refresh the grid.
>Remember that SET DELETED and many other set commands are scoped to the datasession (eg a form with private datasession)
>
>I'd normally only PACK as a maintenance run once a week or once a month depending on the intensity of the application and the file sizes.
>
>HTH
Totally agree with David.
Another method to make the user see it is deleted...
Set Delete Onand you need to add a filter to each Table key definition:
At Index Tab, fill in Filter column with:
!Deleted() for PK!
Then, once the record is deleted, remember to refresh Form and
the record will hide as delete mark is
ON!
The reason why not always pack table:
- it need
Exculsive right, not possible for multi-user use!
- it waste much time to erase record and reindex again!
So, it is not worth to do so.
- In case user wrong delete the record, user can get it back!
That's why Win95 has a rubbish bin for you to Undelete!
Anyway, if you really want to pack the table. Here is the method:
Select NeedPackTable
lRecordKey = NeedPackTable.KeyField
Set Safety Off
Use NeedPackTable Exclusive
Pack
Use in NeedPackTable
Use NeedPackTable again in 0 order tag KeyField Alias ...
Thisform.grid1.recordsourcetype = 0 && Reset to nothing
Thisform.grid1.recordsource = ""
Thisform.grid1.columncount = -1 && Remove orignal Column ... objects
Thisform.grid1.recordsourcetype = 1
Thisform.grid1.recordsource = "NeedPackTable"
Seek &lRecordKey
Set Safety on
ThisForm.refresh
P.s. Anyway, if you really use the above code, you take your own risk!
The weak wait for chance, The strong bid for chance,
The clever notch up chance, but The merciful give you chance.