PDA

View Full Version : [SOLVED] Database or object is read-only



paulked
04-29-2019, 06:13 AM
Hi

I keep getting an error "Cannot update. Database or object is read-only." on the INSERT INTO Goods... line in the code below:


Sub Goods2DB()
RstLog
On Error GoTo Oops
frmWriting.Show
frmWriting.BackColor = Sett.Cells(1, 2)
DoEvents
With CreateObject("ADODB.Connection")
.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=K:\KKDB.accdb;"
.Execute "INSERT INTO TestOpen (TestField) VALUES ('" & Sett.Cells(42, 2) & "') "
.Execute "delete from Goods"
.Execute "insert into Goods SELECT * FROM [Excel 8.0;HDR=YES;DATABASE=" & ThisWorkbook.Name & "].[DBGoods$]"
End With
Unload frmWriting
Xit:
Exit Sub
Oops:
strErrSource = Err.Source
strErrDesc = Err.Description
strErrDetail = "The Goods list has not been updated, please try again."
frmOops.Show
Logger "Err: Goods2DB", Err.Source, Err.Description
Unload frmWriting
End Sub




It executes the INSERT INTO TestOpen and the deletes the contents of the Goods table and then errors. If it was able to delete the contents, why can't it write them?

I'm totally flummoxed and have been Googling for hours (tried all sorts but no luck!)

Any help would be gratefully received!

Thanks, Paul Ked

paulked
04-29-2019, 08:47 AM
It stopped doing it and works now! No re-boot or other changes!