Hi,

I have this code and I am not seeing anything wrong with it but obviously I am wrong.

I am trying to loop through all these records using index 1 (QuoteNo, UwYear, Sectionid, SectionCoverID).

Row QuoteNo UwYear SectionId PremisesID CoverID SectionCoverID
1 136 2021 1 Premises A 18 1
2 136 2021 1 Premises A 18 3319
3 136 2021 1 Premises B 18 3320
4 136 2021 1 Premises A 24 3321
5 136 2021 1 Premises B 24 3322
6 136 2021 3 All Premises 17 1

When executing the code, the first Find (the one before the While loop) gets the first record.
When the code passes through the while loop for the first time, the second record is retrieved, which is correct.
On the next pass, it retrieves the first record again.


Code:
        If (bOK) Begin
            Send Clear of hQuoteMiscTblDD
            Move iQuoteNo to gbquotePolicySectionCover.QuoteNo
            Move iUwyear  to gbquotePolicySectionCover.UwYear
            
            Send Find of hQuoteMiscTblDD GE 1          (gets first record)
            Move (Found) to bFound
            
            If (iQuoteNo <> gbQuotePolicySectionCover.QuoteNo) Move False to bFound
            If (iUwyear  <> gbQuotePolicySectionCover.UwYear)   Move False to bFound       
            While (bFound)
                //                
                Send Clear of hPolicyMiscTblDD
                Set Field_Changed_Value of hPolicyMiscTblDD Field gbPolicySectionCover.PolicyNo to sPolNo            
                For iCnt from 2 to iQuoteMiscTblFields
                    Set Field_Changed_Value of hPolicyMiscTblDD iCnt to (Field_Current_Value (hQuoteMiscTblDD, iCnt))
                Loop
                Set Field_Changed_Value of hPolicyMiscTblDD Field gbpolicySectionCover.CreatedDate to dDate
                Send Request_Save of hPolicyMiscTblDD
                Move (Should_Save(hPolicyMiscTblDD)) to bErr
                If (bErr) Begin
                    Move False to bOk 
                    Error DfErr_Operator 'Policy Section Cover cannot be created.'
                End        
                //
                If (bOK) Begin                                
                    Send Find of hQuoteMiscTblDD GT 1          
                    Move (Found) to bFound
                    If (iQuoteNo <> gbQuotePolicySectionCover.QuoteNo) Move False to bFound
                    If (iUwyear  <> gbQuotePolicySectionCover.UwYear)   Move False to bFound       
                End
                //
            Loop
        End
Thanks in advance,
Jesmond