I have a form based on a set with 6 tables. I want to change the values in a field of a child table (1:many with topparent). I want to change the values of this field in all records.
The child table is displayed in Browse3 on the form that is active.
'consultordcpo' is the name of the child table.
so...
I created the following code:
'Date Created: 26-Aug-2011 10:49:31 AM
'Last Updated: 26-Aug-2011 11:41:23 AM
'Created By : David
'Updated By : David
'Create a new variable called 'TmpRankOnOrder' and set its value to '1
dim cpotbl As P
dim Shared TmpRankOnOrder AS N
TmpRankOnOrder = 1
'Activate object 'BROWSE3:Rankonorder' in current form.
topparent:BROWSE3:Rankonorder.activate()
'get a pointer to the consultordcpo.dbf table... the one that Browse3 is based on
cpotbl = table.get("consultordcpo")
'go to 1st record
cpotbl.fetch_first()
cpotbl.change_begin()
cpotbl.Rankonorder = TmpRankOnOrder
cpotbl.change_end(.t.)
cpotbl.fetch_next()
while .NOT. cpotbl.fetch_eof()
TmpRankOnOrder = TmpRankOnOrder + 1
cpotbl.change_begin()
cpotbl.Rankonorder = TmpRankOnOrder
cpotbl.change_end(.t.)
cpotbl.fetch_next()
end while
'Refresh data in current form at parent level.
'Can only resynch data in View mode, so save record first to be sure that layout is in View mode.
topparent.Commit()
topparent.Resynch()
topparent.Refresh_Layout()
'Disallow editing of records in current form at parent level.
topparent.allow_change(.f.)
end
++++++++++++++++++++++++++++++++++
The code seems to change the values correctly... BUT I have to push the button for each individual record in the child table ie in the browse.
The while loop does not seem to be functioning...
What am i doing wrong?
The child table is displayed in Browse3 on the form that is active.
'consultordcpo' is the name of the child table.
so...
I created the following code:
'Date Created: 26-Aug-2011 10:49:31 AM
'Last Updated: 26-Aug-2011 11:41:23 AM
'Created By : David
'Updated By : David
'Create a new variable called 'TmpRankOnOrder' and set its value to '1
dim cpotbl As P
dim Shared TmpRankOnOrder AS N
TmpRankOnOrder = 1
'Activate object 'BROWSE3:Rankonorder' in current form.
topparent:BROWSE3:Rankonorder.activate()
'get a pointer to the consultordcpo.dbf table... the one that Browse3 is based on
cpotbl = table.get("consultordcpo")
'go to 1st record
cpotbl.fetch_first()
cpotbl.change_begin()
cpotbl.Rankonorder = TmpRankOnOrder
cpotbl.change_end(.t.)
cpotbl.fetch_next()
while .NOT. cpotbl.fetch_eof()
TmpRankOnOrder = TmpRankOnOrder + 1
cpotbl.change_begin()
cpotbl.Rankonorder = TmpRankOnOrder
cpotbl.change_end(.t.)
cpotbl.fetch_next()
end while
'Refresh data in current form at parent level.
'Can only resynch data in View mode, so save record first to be sure that layout is in View mode.
topparent.Commit()
topparent.Resynch()
topparent.Refresh_Layout()
'Disallow editing of records in current form at parent level.
topparent.allow_change(.f.)
end
++++++++++++++++++++++++++++++++++
The code seems to change the values correctly... BUT I have to push the button for each individual record in the child table ie in the browse.
The while loop does not seem to be functioning...
What am i doing wrong?
Comment