Hi,
I am trying to compare two recordsets. the first rs1 has random records. The second rs2 has the standard values for those records. Initially I am looking to take each of the records and see if they match with the standard set of values in the second recordset. There are four fields in each record set to be compared and all four must match.
I just need some help in the loop. I am trying to write the non matching records to an excel file. Here is what I have so far
Also any ideas on how i can segregate based on 2 of fields matching with standard and 3 of the fields matching with the standard values
I am trying to compare two recordsets. the first rs1 has random records. The second rs2 has the standard values for those records. Initially I am looking to take each of the records and see if they match with the standard set of values in the second recordset. There are four fields in each record set to be compared and all four must match.
I just need some help in the loop. I am trying to write the non matching records to an excel file. Here is what I have so far
Code:
While Not rs1.EOF With rs1 .MoveFirst With rs2 .MoveFirst While Not rs2.EOF counter = counter + 1 a = 0 If rs1!Kk = rs2!Kk Then a = a + 1 If rs1!CC = rs2!CC Then a = a + 1 If rs1!HN = rs2!HN Then a = a + 1 If rs3!TN = rs2!TN Then a = a + 1 If a > 3 Then GoTo correct .MoveNext If rs2.EOF Then If rs!Table_Name <> "table1" Then i = i + 1 j = 1 counter = counter + 1 objSht.Cells(i, j).Value = "casenum" & rs1.Fields(1) j = j + 1 stat_counter = stat_counter + 1 End If If i = 65500 Then Set wbexcel = objexcel.ActiveWorkbook ''//Set objSht = wbexcel.Worksheets("Sheet2") Set objSht = wbexcel.Worksheets.Add i = 2 End If End If correct: rs1.MoveNext Wend End With End With
Comment