I am getting an access violation on the last addchildobject i add to my tree? any ideas?
It generates the tree fine just when i go to the form and click on the one that is added last do i get the access violation.
The following code generates the tree:
It generates the tree fine just when i go to the form and click on the one that is added last do i get the access violation.
The following code generates the tree:
Code:
[b]procedure[/b] MakeTheTree(udfName, xName:String; xInt: integer);
[b]var[/b]
xAttdType, xCHAct, TblID: [b]string[/b];
CSREFTBL: TCBTable;
DataPtr: PData;
xEvtType: TEventTypes;
xAttdTypeCh, udfNameCh: [b]String[/b];
[b]begin[/b]
[b]with[/b] AttendanceOptionsFrm [b]do[/b]
[b]begin[/b]
CSREFTBL.Open;
CSREFTBL.GoTop;
[b]IF[/b] xName=[teal]'ALL'[/teal] [b]then[/b] [b]begin[/b]
CSREFTBL.SetFilter([teal]'TBL_NAME="ALL"'[/teal]);
xAttdType:=[teal]'ALL'[/teal];
xEvtType:=ALL;
[b]end[/b];
[b]IF[/b] xName=[teal]'CHACTIVITY'[/teal] [b]then[/b] [b]begin[/b]
CSREFTBL.SetFilter([teal]'TBL_NAME="CHACTIVITY"'[/teal]);
xAttdType:=[teal]'CA'[/teal];
xEvtType:=ChurchActivities;
[b]end[/b];
[b]IF[/b] xName=[teal]'SUNDAYSCHL'[/teal] [b]then[/b] [b]begin[/b]
CSREFTBL.SetFilter([teal]'TBL_NAME="SUNDAYSCHL"'[/teal]);
xAttdType:=[teal]'SS'[/teal];
xEvtType:=SundaySchool;
[b]end[/b];
[b]IF[/b] xName=[teal]'WORSHIP'[/teal] [b]then[/b] [b]begin[/b]
CSREFTBL.SetFilter([teal]'TBL_NAME="WORSHIP"'[/teal]);
xAttdType:=[teal]'WS'[/teal];
xEvtType:=WorshipService;
[b]end[/b];
NEW(DataPtr);
DataPtr^.PID:=udfName;
DataPtr^.Att_Type:=xAttdType;
DataPtr^.UDF_Name:=udfName;
DataPtr^.Event_Tpe:=xEvtType;
DataPtr^.PosNum:= xInt;
SelectedNode:=AttList.Items.AddObject(nil, udfName, DataPtr);
[b]IF[/b] xName<>[teal]'ALL'[/teal] [b]then[/b] [b]BEGIN[/b]
[b]WHILE[/b] [b]not[/b] CSREFTBL.Eof [b]do[/b] [b]Begin[/b]
xCHAct :=CSREFTBL.FieldAsString([teal]'TBL_NAME'[/teal]);
[b]if[/b] CSREFTBL.FieldAsString([teal]'TBL_NAME'[/teal])=xName [b]then[/b] [b]BEGIN[/b]
xCHAct := CSREFTBL.FieldAsString([teal]'DESC'[/teal]);
TblID:=CSREFTBL.FieldAsString([teal]'TBL_ID'[/teal]);
xAttdTypeCh:=[teal]'Attend->'[/teal]+xAttdType+TblID;
udfNameCh:=udfName+[teal]' - '[/teal]+xCHAct;
NEW(DataPtr);
DataPtr^.PID:=TblID;
DataPtr^.Att_Type:=xAttdTypeCh;
DataPtr^.UDF_Name:=udfNameCh;
DataPtr^.Event_Tpe:=xEvtType;
DataPtr^.PosNum:= xInt;
AttList.Items.AddChildObject(SelectedNode, xCHAct, DataPtr);
[b]END[/b];
CSREFTBL.Skip([purple]1[/purple]);
[b]END[/b];
Dispose(DataPtr);
[b]ENd[/b];
CSREFTBL.Close;
[b]end[/b];
[b]end[/b];