PDA

View Full Version : Request for clarification in ParentNullAllowed help



Peter Crook
21-Nov-2011, 12:05 PM
The help for ParentNullAllowed includes:
3d. If IsNullParentAllowed is True, the parent will not be part of the save and and the runtime it will not call Creating (http://support.dataaccess.com/Forums/BaseData_Set-Event-Creating.htm), Update (http://support.dataaccess.com/Forums/BaseData_Set-Event-Update.htm), Validate_Save (http://support.dataaccess.com/Forums/BaseData_Set-Event-Validate_Save.htm), Attach_Main_File (http://support.dataaccess.com/Forums/DataDictionary-Event-Attach_Main_File.htm) or Save_Main_File (http://support.dataaccess.com/Forums/BaseData_Set-Event-Save_Main_File.htm).

I think (hope) it should say: 'If IsNullParentAllowed is True and there is no parent record'......or Save_Main_File in the parent DD.'


(there's also a double 'and' in there).

If this is the case it would be v.useful to have an IsNullParent function as well although maybe a HasParent function would be better:
Function HasParent Integer iParentFile Returns Boolean
Integer iStatus
Get_Attribute DF_FILE_STATUS of iParentFile to iStatus
Function_Return (iStatus = DF_FILE_ACTIVE or iStatus = DF_FILE_ACTIVE_CHANGED)
End_FunctionThen you can write:
Procedure Backout
If (HasParent(Self,SalesP.File_Number)) Begin
Subtract 1 from SalesP.Num_Orders
Subtract OrderHea.Order_Total from SalesP.Order_Value
End
Send Adjust_Balances (-OrderHea.Order_Total)
Forward Send Backout
End_Procedure

Procedure Update
If (HasParent(Self,SalesP.File_Number)) Begin
Add 1 to SalesP.Num_Orders
Add OrderHea.Order_Total to SalesP.Order_Value
End
Send Adjust_Balances OrderHea.Order_Total
Forward Send Update
End_Procedure