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

Batch Deletion 1

Status
Not open for further replies.

paul102384

Programmer
Oct 5, 2007
30
hi to all pb programmers:

how can i delete a batch data in a datawindow sinced i used tabular datawindow?

e.g..

i retrieved 5 records in dw_1. how can i delete a series of records in dw_1, i want to use a selectrow command to select or highlights the records that i want to delete and also to update it automatically.

thanks in advance..
 
So you're wanting to delete all 5 rows? If so...

DO WHILE dw_1.RowCount( ) > 0
dw_1.SelectRow( 0, FALSE )
dw_1.SelectRow( 1, TRUE )
dw_1.DeleteRow( 1 )
LOOP

dw_1.Update( )

//this will basically suck all rows from the top to the bottom, keeping the first row selected
 
tnx thekl0wn, but i need not to delete all the records that i have retrieved... i just want to delete the selectedrow that i have selected using selecrow....
eg... 5 records retrieve, but the selected row is only 3, then only three records should be deleted..

pls. help..
 
Add a column to the DataWindow, and name it something like 'delete_row' and set its value to zero.

Then when you're ready to delete, use this to filter out only the selected rows...

Long ll_row

//loop through rows to set the rows to be deleted
FOR ll_row = 1 TO dw_rpt.RowCount( )
IF dw_rpt.IsSelected( ll_row ) THEN
SetItem( ll_row, 'delete_row', 1 )
END IF
NEXT

//filter to show only those rows to be deleted
dw_rpt.SetFilter( 'delete_row > 0' )
dw_rpt.Filter( )

//delete those rows
DO WHILE dw_rpt.RowCount( ) > 0
dw_rpt.DeleteRow( 1 )
LOOP

//show the rows which did not get deleted
dw_rpt.SetFilter( '' )
dw_rpt.Filter( )
 
tnx thekl0wn for the valuable post, the code helps a lot..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top