Lan
Lan

Reputation: 21

vba - item not found in this collection

I keep keep getting Run-time error '3265':

Item not found in this collection for rstAnswers("20GBRank") = irank while it works in other db.

What am I doing wrong? How can I fix it?

Option Compare Database
Option Explicit

Public Function Update20BldgRank()
Dim db As Database
Dim rstAnswers As Recordset
Dim i As Integer
Dim irank As Integer
irank = 1
Set db = CurrentDb()
Set rstAnswers = db.OpenRecordset("Top20Genbld13", dbOpenDynaset)
rstAnswers.MoveFirst
Do Until rstAnswers.EOF
rstAnswers.Edit
rstAnswers("20GBRank") = irank
rstAnswers.Update
rstAnswers.MoveNext
irank = irank + 1
Loop
rstAnswers.Close
Update20BldgRank = irank - 1
End Function

Upvotes: 1

Views: 8146

Answers (1)

Santosh
Santosh

Reputation: 12353

Just make sure field(column) 20GRank exist in db where you are getting the error.

Upvotes: 2

Related Questions