This topic is locked
[SOLVED]

 Add/Edit works Delete does not

9/4/2015 6:33:45 PM
PHPRunner General questions
greggk author

I have a joined table called orders, consisting of the purchasing table, and the accounting table.

On the orders page, when a record is added, it automatically adds a record with the order number to the accounting table.

I did it with this code on before record is added page:



global $dal;

$tblDetail = $dal->Table("Accounting");

$tblDetail->Value["AorderNUM"] = $values["PorderNUM"];

$tblDetail->Value["paid"] = $values["paid"];

$tblDetail->Add();

unset($values["paid"]);



Then when editing, it also works great, and I used the following code on before record updated page:



global $dal;

$tblDetail = $dal->Table("Accounting");

$tblDetail->Value["paid"] = $values["paid"];

$tblDetail->Param["AorderNUM"] = $values["PorderNUM"];

$tblDetail->Update();

unset($values["paid"]);



So, hey I thought I can add and edit records on multiple tables just fine, how difficult is it to delete? LOL

Turns out it's not as easy to delete, at least I haven't found a way yet.

This is the current code I have in before record is deleted on the list page:



global $dal;

$tblAcc = $dal->Table("Accounting");

$tblAcc->Param["AorderNUM"] = $values["PorderNUM"];

$tblAcc->Delete();


I'm using the exact same method to call up the values for the table Accounting, but it's not deleting. It will delete the record from purchasing, but not from accounting.

Any thoughts of what could be causing this? I know it's something simple I haven't thought of yet.

lefty 9/5/2015



I have a joined table called orders, consisting of the purchasing table, and the accounting table.

On the orders page, when a record is added, it automatically adds a record with the order number to the accounting table.

I did it with this code on before record is added page:



global $dal;

$tblDetail = $dal->Table("Accounting");

$tblDetail->Value["AorderNUM"] = $values["PorderNUM"];

$tblDetail->Value["paid"] = $values["paid"];

$tblDetail->Add();

unset($values["paid"]);



Then when editing, it also works great, and I used the following code on before record updated page:



global $dal;

$tblDetail = $dal->Table("Accounting");

$tblDetail->Value["paid"] = $values["paid"];

$tblDetail->Param["AorderNUM"] = $values["PorderNUM"];

$tblDetail->Update();

unset($values["paid"]);



So, hey I thought I can add and edit records on multiple tables just fine, how difficult is it to delete? LOL

Turns out it's not as easy to delete, at least I haven't found a way yet.

This is the current code I have in before record is deleted on the list page:



global $dal;

$tblAcc = $dal->Table("Accounting");

$tblAcc->Param["AorderNUM"] = $values["PorderNUM"];

$tblAcc->Delete();


I'm using the exact same method to call up the values for the table Accounting, but it's not deleting. It will delete the record from purchasing, but not from accounting.

Any thoughts of what could be causing this? I know it's something simple I haven't thought of yet.



AHh!!!

See my changes in bold. Look at the top of the event you will see paramaters for before delete function BeforeDelete($where, $deleted_values, $message, $pageObject)
Change to :
global $dal;

$tblAcc = $dal->Table("Accounting");

$tblAcc->Param["AorderNUM"] = $deleted_values["PorderNUM"];

$tblAcc->Delete();

greggk author 9/5/2015



AHh!!!

See my changes in bold. Look at the top of the event you will see paramaters for before delete function BeforeDelete($where, $deleted_values, $message, $pageObject)
Change to :
global $dal;

$tblAcc = $dal->Table("Accounting");

$tblAcc->Param["AorderNUM"] = $deleted_values["PorderNUM"];

$tblAcc->Delete();


AHA!!!!! Thank you. I actually figured that out last night myself before I read your post. I kept going over and over different ways, and finally got that. To think, something so simple. <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=77815&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />