Just for information purposes:
Code:
Dim acc1, buysell1, lot1, price1, liq1, Dat1 As String
Dim acc2, buysell2, lot2, price2, liq2, Dat2 As String
creates acc1, buysell1, lot1, price1, liq1, acc2, buysell2, lot2, price2, liq2, as [u]Variants</u>, and only Dat1 and Dat2 as strings...
You will find your own code much easier to read (and others will have an easier time reading your code as well) if you indent. For instance
Code:
If Not Data2.Recordset.EOF Then
Data2.Recordset.MoveNext
End If
Loop
If Not Data1.Recordset.EOF Then
Data1.Recordset.MoveNext
End If
Loop
would be
[u]much</u> easier to follow as
Code:
If Not Data2.Recordset.EOF Then
Data2.Recordset.MoveNext
End If
Loop
If Not Data1.Recordset.EOF Then
Data1.Recordset.MoveNext
End If
Loop
In the following section of code, it took me about 6 seconds to find the green line so as to match it up with the blue line. This should have been automatic through indentation (
[u]0</u> seconds spent).
Code:
Do While Not Data2.Recordset.EOF
Code:
acc2 = Data2.Recordset.Fields(1)
buysell2 = Data2.Recordset.Fields(2)
lot2 = Data2.Recordset.Fields(3)
price2 = Data2.Recordset.Fields(4)
liq2 = Data2.Recordset.Fields(5)
Dat2 = Trim(acc2) & Trim(buysell2) & Trim(lot2) & Trim(price2) & Trim(liq2)
compare2 = Dat2
If StrComp(Trim(Dat1), Trim(Dat2), vbTextCompare) = 0 Then
Data1.Recordset.Delete
Data1.Recordset.MoveNext
If Data1.Recordset.EOF Then
Data1.Recordset.MovePrevious
End If
Data2.Recordset.Delete
Data2.Recordset.MoveNext
If Data2.Recordset.EOF Then
Data2.Recordset.MovePrevious
End If
End If
If Not Data2.Recordset.EOF Then
Data2.Recordset.MoveNext
End If
Loop
Granted, this would have been easier in the IDE through context coloring, but indentation would still have eliminated the time spent scanning the lines of code to find the "If."