G
Guest
I'm trying to update a field in a table with a sequential number. Another
member of this group suggested the following code:
Public Function CalcCatNo() As String
Dim rs As dao.Recordset
Dim db As dao.recordset
Dim sql As String
Dim loopcounter As Long
Set db = CurrentDb()
sql = "SELECT Catalogue.* FROM Catalogue;"
Set rs = db.OpenRecordset(sql)
With rs
.MoveFirst
Do Until .EOF
loopcounter = loopcounter + 1
.Fields("CatalogueNo").Value = loopcounter
.MoveNext
Loop
End With
rs.Close
db.Close
rs = nothing
db= nothing
Firstly I have had to drop the dao in the declarations ie I have :
Dim db As Recordset
Dim rs As Recordset
(why did I need the DAO part is this a key to my problem?)
But now I am stuck at the line: Set rs = db.Openrecordset(sql) I get the
error:
Method or data member not found (Error 461)
Any ideas? Thanks
member of this group suggested the following code:
Public Function CalcCatNo() As String
Dim rs As dao.Recordset
Dim db As dao.recordset
Dim sql As String
Dim loopcounter As Long
Set db = CurrentDb()
sql = "SELECT Catalogue.* FROM Catalogue;"
Set rs = db.OpenRecordset(sql)
With rs
.MoveFirst
Do Until .EOF
loopcounter = loopcounter + 1
.Fields("CatalogueNo").Value = loopcounter
.MoveNext
Loop
End With
rs.Close
db.Close
rs = nothing
db= nothing
Firstly I have had to drop the dao in the declarations ie I have :
Dim db As Recordset
Dim rs As Recordset
(why did I need the DAO part is this a key to my problem?)
But now I am stuck at the line: Set rs = db.Openrecordset(sql) I get the
error:
Method or data member not found (Error 461)
Any ideas? Thanks