A
aeg
I have a table with over 350,000 records, in which i have a field
("ClaimNoCount") to count the unique claim numbers. I have the following
code to do the job but it takes too loooong to run. (Infact I have to
terminate it.) Is it possible to write the following code differently
(perhaps more efficiently)? thanks
Sub SetClaimNoCount()
Dim db As Database
Dim rs As Recordset
Dim tempString As String
Set db = CurrentDb
Set rs = db.OpenRecordset("tbl_AllUnion_PRM") ' or SQL statement
While Not rs.EOF
'rs.MoveFirst
'Debug.Print rs.Fields("ClaimNo")
tempString = rs.Fields("ClaimNo")
rs.MoveNext
If tempString = rs.Fields("ClaimNo") Then
rs.Edit
rs!ClaimNoCount = 0
rs.Update
Else
rs.Edit
rs!ClaimNoCount = 1
rs.Update
End If
Wend
rs.Close
db.Close
Set rs = Nothing
Set db = Nothing
End Sub
("ClaimNoCount") to count the unique claim numbers. I have the following
code to do the job but it takes too loooong to run. (Infact I have to
terminate it.) Is it possible to write the following code differently
(perhaps more efficiently)? thanks
Sub SetClaimNoCount()
Dim db As Database
Dim rs As Recordset
Dim tempString As String
Set db = CurrentDb
Set rs = db.OpenRecordset("tbl_AllUnion_PRM") ' or SQL statement
While Not rs.EOF
'rs.MoveFirst
'Debug.Print rs.Fields("ClaimNo")
tempString = rs.Fields("ClaimNo")
rs.MoveNext
If tempString = rs.Fields("ClaimNo") Then
rs.Edit
rs!ClaimNoCount = 0
rs.Update
Else
rs.Edit
rs!ClaimNoCount = 1
rs.Update
End If
Wend
rs.Close
db.Close
Set rs = Nothing
Set db = Nothing
End Sub