Gday all
I have been using Peter Wayne script for duplicating a set with a parent and single child with never a problem. I now want to do duplicate a set with multiple children. I have managed to duplicate the first child OK, but the 2nd child duplicates the correct amount of records although the data is the same in every record (image attached).
I have pasted the script beneath and hopefully someone can point out where I am going wrong.
Many thanks
Paul
dim hdr as p
dim items as p
dim old_parent as b29-12-2012 5-23-53 PM.jpg29-12-2012 5-23-53 PM.jpg
dim old_items as b
dim count_items as n
dim i as n
dim hdr1 as p
dim items1 as p
dim old_parent1 as b
dim old_items1 as b
dim count_items1 as n
dim i1 as n
hdr=table.current(1)
items=table.current(3)
items1=table.current(6)
count_items = count(d5qucon->d5quoteid,GRP->d4quote)
if count_items>0 then
dim records[count_items] as b
i=0
items.fetch_first()
while i<count_items
i=i+1
records[i]=items.record_data_get()
items.fetch_next()
end while
end if 'count_items>0
'
count_items1 = count(d8quitm->d8quoteid,GRP->d4quote)
if count_items1>0 then
dim records1[count_items1] as b
i1=0
items1.fetch_first()
while i1<count_items1
i1=i1+1
records1[i]=items1.record_data_get()
items1.fetch_next()
end while
end if 'count_items1>0
'
old_parent=hdr.record_data_get()
hdr.enter_begin()
hdr.record_data_set(old_parent)
hdr.d4quotdate=date()
hdr.enter_end(.t.)
if count_items>0 then
for i=1 to count_items
items.enter_begin()
d5qucon.d5quconid=items.recno()+1
items.record_data_set(records[i])
d5qucon.d5quoteid=hdr.d4quoteid
items.enter_end(.t.)
next
end if
'
if count_items1>0 then
for i1=1 to count_items1
items1.enter_begin()
d8quitm.d8quitemid=items1.recno()+1
items1.record_data_set(records1[i])
d8quitm.d8quoteid=hdr.d4quoteid
items1.enter_end(.t.)
next
end if
'
parent.resynch()
I have been using Peter Wayne script for duplicating a set with a parent and single child with never a problem. I now want to do duplicate a set with multiple children. I have managed to duplicate the first child OK, but the 2nd child duplicates the correct amount of records although the data is the same in every record (image attached).
I have pasted the script beneath and hopefully someone can point out where I am going wrong.
Many thanks
Paul
dim hdr as p
dim items as p
dim old_parent as b29-12-2012 5-23-53 PM.jpg29-12-2012 5-23-53 PM.jpg
dim old_items as b
dim count_items as n
dim i as n
dim hdr1 as p
dim items1 as p
dim old_parent1 as b
dim old_items1 as b
dim count_items1 as n
dim i1 as n
hdr=table.current(1)
items=table.current(3)
items1=table.current(6)
count_items = count(d5qucon->d5quoteid,GRP->d4quote)
if count_items>0 then
dim records[count_items] as b
i=0
items.fetch_first()
while i<count_items
i=i+1
records[i]=items.record_data_get()
items.fetch_next()
end while
end if 'count_items>0
'
count_items1 = count(d8quitm->d8quoteid,GRP->d4quote)
if count_items1>0 then
dim records1[count_items1] as b
i1=0
items1.fetch_first()
while i1<count_items1
i1=i1+1
records1[i]=items1.record_data_get()
items1.fetch_next()
end while
end if 'count_items1>0
'
old_parent=hdr.record_data_get()
hdr.enter_begin()
hdr.record_data_set(old_parent)
hdr.d4quotdate=date()
hdr.enter_end(.t.)
if count_items>0 then
for i=1 to count_items
items.enter_begin()
d5qucon.d5quconid=items.recno()+1
items.record_data_set(records[i])
d5qucon.d5quoteid=hdr.d4quoteid
items.enter_end(.t.)
next
end if
'
if count_items1>0 then
for i1=1 to count_items1
items1.enter_begin()
d8quitm.d8quitemid=items1.recno()+1
items1.record_data_set(records1[i])
d8quitm.d8quoteid=hdr.d4quoteid
items1.enter_end(.t.)
next
end if
'
parent.resynch()
Comment