Link to home
Start Free TrialLog in
Avatar of Jimbo99999
Jimbo99999Flag for United States of America

asked on

VB.Net - Conversion from VB6 to VB.Net Looping Translation

Good Day Experts!

The end is in site for my little conversion project.  This is the last part of the code that has errors.  I just am not sure how the VB6 constructs are working here to follow a couple parts in the code.  

***tblRS is a detached “table” recordset populated in code above this block
***SQLrs2 is a recordset from a query farther up in the code
I just don’t understand looping on tblRS since once inside the Loop for SQLrs2
tblRS.Find is executed.  Also, I cannot follow the MoveNext, First and Last near
the bottom.  

Can you help translate?

Do Until tblRS.EOF = True
SQLrs2.MoveFirst
        Do Until SQLrs2.EOF = True
            tblRS.Find "[GL CODE]='" & SQLrs2("GL CODE") & "'"
            Debug.Print "[GL CODE]='" & SQLrs2("GL CODE") & "'"
            If tblRS.EOF = True Or tblRS.BOF = True Then
               Debug.Print "NOT FOUND ADDING " & SQLrs2("GL CODE")
               'Not found add new record...
               Dim fieldsArray1(2) As Variant
               fieldsArray1(0) = "GL CODE"
               fieldsArray1(1) = "TotalPaid"
               fieldsArray1(2) = "TotalWeight"
               Dim values1(2) As Variant
               values1(0) = SQLrs2("GL CODE")
               values1(1) = SQLrs2("TotalPaid")
               values1(2) = SQLrs2("TotalWeight")
               tblRS.AddNew fieldsArray1, values1
               tblRS.Update
            Else        
                'Add the total paid to the Original Query results
                tblRS("TotalPaid") = CDec(tblRS("TotalPaid").Value) + CDec(SQLrs2("TotalPaid").Value)
                tblRS("TotalWeight") = CDec(tblRS("TotalWeight").Value) + CDec(SQLrs2("TotalWeight").Value)
            End If
            SQLrs2.MoveNext
            tblRS.MoveFirst
        Loop
        tblRS.MoveLast
        tblRS.MoveNext
    Loop
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jimbo99999

ASKER

I will look at doing that if I cannot find a resultion to direct translate.