This is code that I have placed in the field-rules - Events - Record - canDeleteRecord event...
if (A_DELETING_RECORD = .T.) then
'check if a record exists in the ordermemo table... if so delete it!
if exist(orders->ordernum,"ordermemo","Ordernum") = .t. then
ui_msg_box("There is an associated memo for this Order","It will be deleted.",UI_ATTENTION_SYMBOL+UI_OK)
Delete_Count as N = RECORD_DELETE("ordermemo", "Ordernum = " + alltrim(str(Orders->Ordernum)))
'ui_msg_box("ASSOCIATED MEMO WAS DELETED FROM ORDERMEMO TABLE","DETETE_COUNT = " + alltrim(str(delete_Count)),UI_INFORMATION_SYMBOL+UI_OK)
ui_msg_box("ASSOCIATED MEMO WAS DELETED FROM ORDERMEMO TABLE","Associated memo was deleted from OrderMemo table.",UI_INFORMATION_SYMBOL+UI_OK)
end if
'check if records exists in the orderdetail table... if so delete them!
if exist(orders->ordernum,"orderdetail","Ordernum") = .t. then
ui_msg_box("There are associated products on this Order","They will be deleted.",UI_ATTENTION_SYMBOL+UI_OK)
Delete_Count as N = RECORD_DELETE("orderdetail", "Ordernum = " + alltrim(str(Orders->Ordernum)))
ui_msg_box("ASSOCIATED ORDERED PRODUCTS WERE DELETED FROM ORDERDETAIL TABLE","DELETE_COUNT = " + alltrim(str(delete_Count)),UI_INFORMATION_SYMBOL+UI_OK)
end if
'check if records exists in the consultordcpo table... if so delete them!
if exist(orders->ordernum,"consultordcpo","Ordernum") = .t. then
ui_msg_box("Consultants have been assigned to Order","Their associations will be deleted.",UI_ATTENTION_SYMBOL+UI_OK)
Delete_Count as N = RECORD_DELETE("consultordcpo", "Ordernum = " + alltrim(str(Orders->Ordernum)))
ui_msg_box("ASSOCIATED CONSULTANTS WERE DELETED FROM CONSULTORDCPO TABLE","DELETE_COUNT = " + alltrim(str(delete_Count)),UI_INFORMATION_SYMBOL+UI_OK)
end if
end if
===================================================================================
the records are correctly deleted from the ordermemo table...
but the script fails on the orderdetail delete... the error message stated that "...the table is not in change or enter mode"
How can I get these records deleted?
if (A_DELETING_RECORD = .T.) then
'check if a record exists in the ordermemo table... if so delete it!
if exist(orders->ordernum,"ordermemo","Ordernum") = .t. then
ui_msg_box("There is an associated memo for this Order","It will be deleted.",UI_ATTENTION_SYMBOL+UI_OK)
Delete_Count as N = RECORD_DELETE("ordermemo", "Ordernum = " + alltrim(str(Orders->Ordernum)))
'ui_msg_box("ASSOCIATED MEMO WAS DELETED FROM ORDERMEMO TABLE","DETETE_COUNT = " + alltrim(str(delete_Count)),UI_INFORMATION_SYMBOL+UI_OK)
ui_msg_box("ASSOCIATED MEMO WAS DELETED FROM ORDERMEMO TABLE","Associated memo was deleted from OrderMemo table.",UI_INFORMATION_SYMBOL+UI_OK)
end if
'check if records exists in the orderdetail table... if so delete them!
if exist(orders->ordernum,"orderdetail","Ordernum") = .t. then
ui_msg_box("There are associated products on this Order","They will be deleted.",UI_ATTENTION_SYMBOL+UI_OK)
Delete_Count as N = RECORD_DELETE("orderdetail", "Ordernum = " + alltrim(str(Orders->Ordernum)))
ui_msg_box("ASSOCIATED ORDERED PRODUCTS WERE DELETED FROM ORDERDETAIL TABLE","DELETE_COUNT = " + alltrim(str(delete_Count)),UI_INFORMATION_SYMBOL+UI_OK)
end if
'check if records exists in the consultordcpo table... if so delete them!
if exist(orders->ordernum,"consultordcpo","Ordernum") = .t. then
ui_msg_box("Consultants have been assigned to Order","Their associations will be deleted.",UI_ATTENTION_SYMBOL+UI_OK)
Delete_Count as N = RECORD_DELETE("consultordcpo", "Ordernum = " + alltrim(str(Orders->Ordernum)))
ui_msg_box("ASSOCIATED CONSULTANTS WERE DELETED FROM CONSULTORDCPO TABLE","DELETE_COUNT = " + alltrim(str(delete_Count)),UI_INFORMATION_SYMBOL+UI_OK)
end if
end if
===================================================================================
the records are correctly deleted from the ordermemo table...
but the script fails on the orderdetail delete... the error message stated that "...the table is not in change or enter mode"
How can I get these records deleted?
Comment