Isaac
Lifelong Learner
- Local time
- Today, 07:41
- Joined
- Mar 14, 2017
- Messages
- 8,778
I have some code that allows a user to add one attachment to a Sharepoint list. Sometimes, but not always, and seemingly at random (or I can't figure out a pattern), the error will be raised "Cannot update. Database or object is read-only". Then I'll go in to the same screen and it will work for me - just kind of hit or miss.
Is there anything about this code that would give rise to that, that anyone can tell? There is nothing else in the Sub prior to this point that messes with this record in any way - this is the first type of edit of any kind.
Is there anything about this code that would give rise to that, that anyone can tell? There is nothing else in the Sub prior to this point that messes with this record in any way - this is the first type of edit of any kind.
Code:
Set rsMain = db.OpenRecordset("select col1,attachments from [tablename] where id=" & Me.listRecords.Column(0))
rsMain.Edit
Set rsAttachments = rsMain.Fields("Attachments").Value
rsAttachments.AddNew
rsAttachments.Fields("FileData").LoadFromFile Me.txtPath.Value
rsAttachments.Update '********************************************this is where the code debugs when they get the error
rsMain.Fields("col1") = strFileName
rsMain.Update
rsMain.Close
Set rsMain = Nothing