Topic: delete from tablegrid
It is possible if we delete data from tablegrid then concerned text in a text box should also delete. How it will be?
My Visual Database → General → delete from tablegrid
It is possible if we delete data from tablegrid then concerned text in a text box should also delete. How it will be?
When you delete data in the TableGrid they are also deleting text boxes.
if text box belong to an other table then?
It will also be deleted since the data is entered in a database which corresponds with the tables and the text zones. Try it and you will understand.
I am sorry. I want to know when we delete a record from tablegride, it must also clear the data on text box of same form.
It sounds as if you are using the same form to edit a record as you are to display the tablegrid.
This is not 'standard' MVD but obviously can still be done quite easily.
But you will find that if you delete a record from the tablegrid, you will then have to write a small script to delete any associated edit fields, comboboxes etc.
As always, if you attach your project, it will make it easier for people to understand your exact problem rather than having to make assumptions.
Derek.
Hi derek
look at this project. When I enter sale on sale form it will appear on tablegrid and I type costumer's name. In case costumer refuse to buy then I delete record from tablegrid then costumer name should also be cleared.
hi derek
look at attached pic too
If all you want to do is clear out the edit field, then just change this procedure as follows:
procedure Sales_Button5_OnAfterClick (Sender: TObject);
begin
if sales.tablegrid1.rowcount = 0 then sales.edit4.clear;
UpdateTicketTotalSales(Sales.btnSave.dbGeneralTableId);
end;
Derek.
Thank you derek. It works but it does not work when I select row and hit delete key or select row and click right mouse button.
If you are selecting a row and a) hitting the 'delete' key or b) right-clicking, then I have to assume that you are using an editable grid; it would have been helpful to have known this.
Simply add the code to the 'onchange' event of the tablegrid instead.
.
procedure Sales_TableGrid1_OnChange (Sender: TObject);
begin
if sales.tablegrid1.rowcount = 0 then sales.edit4.clear;
//Sales.stotal.Value:= Sales.TableGrid1.Columns[1].Footer.Formulavalue;
//ComputeReceivable;
end;
Thank you derek you have solved my issue which is about one row in tablegrid. One thing more I would like to ask if there is more then one rows in tablegrid and more then one text box then how this statement would be?
Всем привет подскажите решение:
Есть таблица и кнопка удалить. Если в таблице не выделена запись то открывается форма Form2 и там уже сообщение что не выбрана запись. Если запись выбрана то она скриптом удаляться
procedure Form1_Button3_OnClick (Sender: TObject; var Cancel: boolean);
begin
Cancel := True;
if Form1.TableGrid1.dbItemID then
begin
if Confirm('Are you sure you want to delete customer? This will make its children orphan. Proceed?') then
begin
// make tele Customer to delete orphan
SQLExecute(DELETE tele SET id_Customer = NULL WHERE id_Customer = '+IntToStr(Form1.TableGrid1.dbItemID));
// proceed to delete.
Cancel := False;
end;
end else
ShowMessage('Cannot proceed without selected record');
end;
{
Comfirm massages with "Yes or No"
}
function Confirm(msg: String='Please Confirm.'; ICON: Integer=MB_ICONQUESTION; title:String='Confirm'): boolean;
begin
result := IDYES = MessageBox(msg, 'APPNAME : '+title, MB_YESNO+ICON);
end;.
Всем привет подскажите решение:
Есть таблица и кнопка удалить. Как выглядит скрипт? Если в таблице не выделена запись то открывается форма Form2 и там уже сообщение что не выбрана запись. Если запись выбрана то она удаляется скриптом причем все связанные с ней записи.
?
My Visual Database → General → delete from tablegrid
Powered by PunBB, supported by Informer Technologies, Inc.
Theme Hydrogen by Kushi