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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

delete/pack -> grid in form goes "white" 1

Status
Not open for further replies.

nicuschor

Programmer
May 8, 2003
5
RO
Suppose I have a grid in a form,showing a table's content.
(application single user, VFP6)
I "delete" one or more records (mark on delete column), then push a command button with "pack" command line.
The grid goes blank.
I tried to refresh, etc. Nothing works.
Solution I use now (It works but I don't like it):
instead of

pack

I use

copy all for deleted()=.f. to ....
zap
appe from ...

You know a good way to do the "pack"?

Best regards,

 
nicuschor

WITH THISFORM.Grid1
[tab].RecordSource = []
[tab]PACK IN MyTable
[tab].RecordSource = [MyTable]
[tab].Refresh()
ENDW




FAQ184-2483 - the answer to getting answered.​
Chris [pc2]
 
try changing the recordsource to nothing, then back to the table.

with this && where this is the grid
.recordsource=""
.recordsource=mytable
endwith

MrF
 
Hi nicuschor,

What Chris said will work.
Also you can think of making a different approach.

1. SET DELETED ON along with your other SET commands.
2. Whenever you delete a record, move the pointer to the pevious record.. example..

DELETE
SKIP -1

and also refresh the grid and set the focus back to the grid. This is top ensure that the deleted record is removed from the visual appearance of the grid. :)

The pack command creates the problem, because, it momemtarily closes the table and opens it making the grid loose its record source. Once you specify the record source as "", it is not getting affected and after the table is available, you are refreshing it again with the record source.
:)

ramani :)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com

 
Ramani's trick is pretty good, but remember to test for BOF() before doing the skip-1

Code:
Delete
if !bof()
  skip-1
else
  go top
endif


Regards

Griff
Keep [Smile]ing
 
Vbarph
Hello. I might help you regarding your problem try to select TOOLS in your VFP menu and choose OPTION a dialog window pops-up select DATA in pageframe and CHECK the checkbox ignore deleted records and SET AS DEFAULT...

then during you close your application define/use the tables where you delete the records and pack.

 
vbarph

hen during you close your application define/use the tables where you delete the records and pack.

Hopefully this is a standalone application, as this scenario would not work if it's a multiuser application.



Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
In addition, don't pack a file during program operations.

Set deleted on so the records just don't show and move any
packing of tables to a table maintenance process.

Also, add an index filter of .NOT.DELETED() to any index
tags. That way you'll also avoid uniqueness errors when
adding new records to tables. (note: there is a not so
obvious relation between records that are deleted to not
deleted that can affect performance when you have .NOT.DELETED() filter set)

On large tables, packing the tables during operation causes
very annoying delays.

Darrell

'We all must do the hard bits so when we get bit we know where to bite' :)
 
Just out of curiosity how could you do it if it were a multiuser application?

Thanks in advance!!!
 
Kerbouchard

Just out of curiosity how could you do it if it were a multiuser application?

If you need to show data in a grid, that will not require editing, use a cursor that will get destroyed when you leave or recreate the table in a temp directory on the user's machine, everytime you recreate the table (with CREATE TABLE) you end up with an empty table, no need to delete or pack.



Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top