Originally Posted by
pbaldy
Another shot, make sure there isn't a form open that's bound to the same table. That error can happen when a form is bound to a table and you edit data with code.
No forms are open... I'm testing the procedure by itself.
I've seen similar behavior before involving field accesses after MoveNext returning the previous row's data. Here's some code in my project that I wrote to work around that one:
Code:
' Key-value pairs from the DBConfig table
Public dbConfig As New Scripting.Dictionary
...
Public Sub initialize()
...
' Load the key-value pairs from DBConfig to a dictionary for global use
dbConfig.RemoveAll
Dim rs As DAO.Recordset, key As String, val As String
Set rs = baseDb.OpenRecordset("DBConfig", dbOpenTable, dbReadOnly)
Do While Not rs.EOF
key = rs!key
val = rs!val
' Don't rewrite the following with rs!key and rs!val...
' you'll get a duplicate key error (likely a bug in the library)
dbConfig.Add key, val
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
...
End Sub