Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Deleting the child records of a form
Message
From
22/05/2003 14:34:11
 
 
To
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Deleting the child records of a form
Miscellaneous
Thread ID:
00791822
Message ID:
00791822
Views:
46
Hello cetin, Please help me on this.
I have this code in the class.

This code is used to delete the master record and after deleting the master record .it will look for all the child tables of this form and has to delete those child records also.

In the form's dataenvironment i have the event used (beforeopenTables Event) in that all the cursor names are mentioned.

But when i do the delete on the form it reads this code when it comes to the below point.

=AMEMBERS(A_Cursors,THISFORMset.dataenvironment,1)
=ASORT(A_Cursors, 2)
nStartpos=ASUBSCRIPT(A_Cursors, ASCAN(A_Cursors, "Object"),1)

--COMMENT---Some thing is not working here do i need to mention about the beforeopentables event in the above code please tell me can i do this(THISFORMset.dataenvironment.beforeopentables)

And in the A_Cursors i am getting "INIT" i guess it is looking for init event of dataenvironment instead it should look in beforeopentables event of the form's dataenvironment.



**********I am pasting this code which is where it is not finding any cursors at all and bypassing the if condition****************


IF DeleteRecord
if deleted() THEN
RECALL
ELSE
DELETE
ENDIF

mParentId = EVAL(this.MasterTableId)
set step on
* Make a list of all the cursors in the Data Environment
=AMEMBERS(A_Cursors,THISFORMset.dataenvironment,1)
=ASORT(A_Cursors, 2)
nStartpos=ASUBSCRIPT(A_Cursors, ASCAN(A_Cursors, "Object"),1)
set step on
* find the child records and delete or recall
FOR I = nStartpos TO ALEN(A_Cursors,1)
IF A_Cursors(I,2) = "Object"
cObjClass = "THISFORMset.DATAENVIRONMENT."+A_Cursors(I,1)+".class"
IF EVAL(cObjClass)="Relation"
cObjName="THISFORMset.DATAENVIRONMENT."+ A_Cursors(I,1)+".parentAlias"
cObjChild = "THISFORMset.DATAENVIRONMENT."+ A_Cursors(I,1)+".childAlias"
cObjChildOrder = "THISFORMset.DATAENVIRONMENT."+ A_Cursors(I,1)+".childorder"
Parent_Name=EVAL(cObjName)
Child_Name = eval(cObjChild)
Child_Order = eval(cObjChildOrder)
IF UPPER(Parent_name) = UPPER(sTable)

***********************************END**********************************************
Next
Reply
Map
View

Click here to load this message in the networking platform