Runtime Error 3001?!?!?!

kwokv616

Registered User.
Local time
Yesterday, 20:00
Joined
Nov 10, 2008
Messages
46
I have written the following code:

Sub UpdateIL4010DB()

Dim rst As DAO.Recordset
Dim tbl As DAO.TableDef
Dim db As DAO.Database
Dim fld As DAO.Field
Dim indx As DAO.Index

Set db = CurrentDb
Set tbl = db.TableDefs("Rid")

Set rst = db.OpenRecordset("Rid", dbOpenTable)

rst.MoveFirst
Do
If IsNull(rst![Rcode]) Then
rst.Edit
rst![Rcode] = rst!
Code:
            rst.Update
        End If
        rst.MoveNext
    Loop Until (rst.EOF)
    rst.Close
  
End Sub
 
 
The number of records to be read is about 2000000 records, and the runtime error occurs somewhere in the middle.
At first i thought the problem was the database becoming too large with too much data, causing the problem, but then i realised it jumps to over 2GB once the problem occurs. Which means, the problem caused the large size, instead of the other way round.
 
So i need to know why it caused runtime '3001' in order to make the program run successfully. Please help me!! 
 
Thank you!!!
 
It would probably be way, way, way more efficient to do something like this
Code:
[FONT="Verdana"]Sub UpdateIL4010DB()
  CurrentDb.Execute _
    "UPDATE Rid " & _
    "SET Rcode = code " & _
    "WHERE Rcode Is Null;"
End Sub[/FONT]
 
Hi, Thank you.
but what if i want to put values from another table into the current table, how do i do it?

Sub UpdateIL4010DB()

Dim rst As DAO.Recordset
Dim tbl As DAO.TableDef
Dim db As DAO.Database
Dim fld As DAO.Field
Dim indx As DAO.Index

Set db = CurrentDb
Set tbl = db.TableDefs("Rid")

Set rst_r = db.OpenRecordset("Rid", dbOpenTable)
Set rst_p = db.OpenRecordset("Pol", dbOpenTable)


rst.MoveFirst
Do
If (IsNull(rst_r![rcode]) AND (rst_r![Pnumber]=rst_p![Pnumber])) Then
rst_r.Edit
rst_r![rcode] = rst_p![rcode]
rst_r.Update
End If
rst.MoveNext
Loop Until (rst.EOF)
rst.Close

End Sub


I tried Currentdb.Execute "UPDATE Rid SET Rcode = [Pol].[Rcode] WHERE [Pol].[Pnumber]=[Rid].[Pnumber];" but doesnt work....:(
 

Users who are viewing this thread

Back
Top Bottom