Hi all, is there anyone out there that can help me replicate the below VBA code into SQL? Obviously I have no problem with the select statement but it the looping that I'm trying to recreate in SQL in vain.
Thanks in advance
--------------
sqlstring2 = "SELECT M_Rel_Ttemp.wh_acc_no, M_Rel_Ttemp.wh_cust_no, M_Rel_Ttemp.cluster_no FROM Mortgage_Rel_Temp ORDER BY M_Rel_Ttemp.wh_acc_no ASC, M_Rel_Ttemp.cluster_no ASC"
Set rst2 = thedb.OpenRecordset(sqlstring2, dbOpenDynaset)
rst2.MoveFirst
prev_fac = rst2!wh_acc_no
prev_cust = rst2!wh_cust_no
prev_clus = rst2!cluster_no
rst2.MoveNext
For i = 2 To rwnbr
If rst2!cluster_no <> prev_clus Then
If rst2!wh_acc_no = prev_fac Then
rst2.Edit
rst2!cluster_no = prev_clus
ChangeCount = ChangeCount + 1
rst2.Update
Else
End If
Else
End If
prev_fac = rst2!wh_acc_no
prev_cust = rst2!wh_cust_no
prev_clus = rst2!cluster_no
rst2.MoveNext
Next i
rst2.Close
-----------------------