FrançaisEnglishEspañol
PC SOFTForums homeLast messagesOnline repository
PC SOFT
Find...
Perform the searchSearch in...
Newsgroup dedicated to WINDEV (current version), in English
Re: Deleting a record from a Browsing Table
Dec., 10th 2009 at 09:42 AM
SolutionJ-Reg
<gu...st@news.pcsoft.fr>


Yep, you're spot on...
I've just this second got it working! the code below is set in the Click event of a table column which contains an image of the recycling bin (ie "delete this row").
LP_DisplayLine fills the detail part of the form with data from the selected row of TABLE_Details - so if they decide to delete a row othr than they one they've currently got selected it will become the selected row and its details will be displayed befoer they're prompted to confirm the deletion.
GP_Saverecord does the HDelete bit (using the current record setting).
gnTablerow is set using the TableInfo contruct in the table's Left Button Down event to tell me which row was clicked for deletion.
After GP_Saverecord has deleted the record, if there are no rows left then BTN_NEW sets the user up to add the first row, otherwise the code selects the row that came after the deleted row (or the new last row if the last row was deleted).
If anything looks silly in this code please let me know; I do not pretend to be a WD guru by any means!! :)
Cheers
Reg
TableSelectPlus(TABLE_DETAILS,gnTablerow)
LP_DisplayLine()
IF YesNo(0,"Are you sure you want to delete this line?") = Yes THEN
GP_Saverecord(MyWindow..Name,"SALESQUOTATIONSPECIFICATION","D"," ")
TableDisplay(TABLE_DETAILS,taReExecuteQuery)
TableSelectMinus(TABLE_DETAILS)
IF TableCount(TABLE_DETAILS) < 1 THEN
ExecuteProcess(BTN_NEW,trtClick)
ELSE
IF TableCount(TABLE_DETAILS) > 0 THEN
gnTablerow = TableCount(TABLE_DETAILS)
END
TableSelectPlus(TABLE_DETAILS,gnTablerow)
LP_DisplayLine()
END
SetFocus(TAB_Tab1.COMBO_SPECIFICATION)
END