Hi,
i have 3 Tables....
1. Table has Key: Name
2. Table has Key: Name, Subname
Subname
3. Table has Key, Name, Subname, LineNo
When i delete Data from Table 1 i would that all Datarows in Table 2 that have the same Name will too deleted and delete all Datarows in Table 3 what have the Same Name and Subname was deleted in Table 2.
For Example:
Table1
Name Desription
Mercedes German Car
Peugeot French Car
Table2:
Name Subname
Mercedes C-Class
Mercedes A-Class
Mercedes S-Class
Peugeot 206CC
Peugeot 306cc
Peugeot 106
Table3:
Name Subname LineNo Colour
Mercedes C-Class 10000 red
Mercedes A-Class 10000 red
Mercedes A-Class 20000 green
Mercedes S-Class 10000 blue
Peugeot 206CC 10000 black
Peugeot 206CC 20000 yellow
Peugeot 306cc 10000 white
Peugeot 106 10000 pink
When I Delete from Table1 the Data with Name Mercedes, it must be delete follow data from Table2:
Mercedes C-Class
Mercedes A-Class
Mercedes S-Class
And Follow Data from Table 3:
Mercedes C-Class 10000 red
Mercedes A-Class 10000 red
Mercedes A-Class 20000 green
Mercedes S-Class 10000 blue
Then when in Table 2 i delete the datarow "Mercedes C-Class"
It must delete from Table3 follow Datarows:
Mercedes C-Class 10000 red
My Problem is that when i start the onDelete Trigger in Table1 , that it only deletes this datarow, and when it was deleted i don't know keys for delete Data in Table2.
Or must i put this Function in a Form for delete the data from the other tables ? Perhaps in OnDeleteRecord Trigger ?
I Hope you understand what i mean and can help me giving some tipps.
Thanks.
PS:
Code in Table1:
onDelete()
recTable2.SETRANGE(Name,Name);
IF recTable2.FIND('-') THEN
recTable2.DELETEALL(TRUE);
Code in Table2:
onDelete()
recTable3.SETRANGE(Name, Name);
recTable3.SETRANGE(Subname, Subname);
IF recTable3.FIND('-') THEN
recTable3.DELETEALL(FALSE);
THANKS AGAIN
Comments
This code seems OK for me...
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
But when i want to delete one Row from the first table it says me that the row of Table2 can't find it ...
But the Row exists with the expected Keys ... :-k
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
in Table2
OnDelete()
When i would delete Row in table 2 the Error Message what came is:
Entry not found Keys expected:
Name = "Name"
Subname = "Subname"
LineNo = 10000
But in Table3 exists a Row with this Values.
And what you have in table3 in ondelete?
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
:oops: :oops: :oops: :oops:
In onDelete() in Table3 i had a Funktion what Sorts me any rows after delete one , and in this function i was set a filter for counting and sorting my entries.
When i Comment Out this function, it works nice delete all entries, i think that i put my sort function in the onDelte Trigger in the Form, then it must be okay.