Delete record in subform
Delete record in subform
How it's possible to create a button (delete) to delete 1 record in subform with the same effect of the keys F7 and delete subform(only) without having to choose the option?
Re:Delete record in subform
You are making a valid point.
It is annoying to have to select in a dialogue what you want to delete.
The simplest solution to avoid this is simply to use ExecDQL.
Create a button with the Action: Execute Function/Derivation
Then write in a derivation like this.
ExecDQL("delete records in MySubFormTable with UniqueID=data-entry field1.",UniquId)+RecordSave()
UniqueID is a field on the subform table that is unique for each row/record so you can identify the record 100%.
The recordSave is just added to get the SubForm to update the view so the row will disappear visibly too.
Depending on how the maindata form is opened you might use FormClear(), SelectionFilter() etc to requery it.
Re:Re:Delete record in subform
ExecDQL is OK ! my ExecDQL("delete records in Schededett with NumID=data-entry field1",NumID)+RecordSave() delete record but in the screen not clear record deleted, it need to close and reopen form to have a correct view
Re:Re:Re:Delete record in subform
Hi again.
As the record is deleted by the DQL and not the GUI the current form don't realize that it has changed and hence don't re-read the data from the database.
What you have to trigger is this, and there is a number of ways.
1. If you have used OpenRelated when you opened the form with the subform you can simply call FormClear()
ExecDQL("delete records in MySubFormTable with UniqueID=data-entry field1.",UniquId)+FormClear()
2. If this is a normal form that you have search up or are entering now, you need to trigger DataEase to re-read the subform. You can do that by "dirtying" the relationship key.
ExecDQL("delete records in MySubFormTable with UniqueID=data-entry field1.",UniquId)+SetVar("TempStore",MySubFormRelKey)+SetValue("MySubFormRelKey","")+SetValue("MySubformRelKey",GetVar("TempStore"))
The idea is that that you temporary save the relkey, clear it and then reset it. This will trigger a re-read of the subform.
Beware that the Objectname of a Field and the ColumnName not necessarily are the same and that when you address the objectname you have to "quote it" and when you reference the column you don't.