cannot update. Database or object is read-only

S

Sandy

I have this annoying bug that is driving me up the wall. This code used to
work but has suddenly stopped. When a user closes the report, if they answer
Yes to the prompt, I want a field called Invoiced to be set to true.

If anyone can help, I'd really appreciate it.

The code I am using is:

Private Sub Report_Close()

Dim strMess As String
Dim rs As Recordset
Dim rsInvNo As Recordset

If Not blnReprint Then
strMess = "Would you like to mark the displayed dockets as
Invoiced?" & vbLf
strMess = strMess & "If you select Yes, you will not be able to
invoice these dockets again."

If MsgBox(strMess, vbYesNo + vbQuestion, gstrAppName) = vbYes Then
If glngCustomerID > -1 Then
Set rs = DBEngine(0)(0).OpenRecordset("SELECT * from
qryInvoice WHERE DocketDate between #" & getStartDate() & "# and #" &
getEndDate() & "# AND CustomerID = " & getCustID())
Else
Set rs = DBEngine(0)(0).OpenRecordset("SELECT * from
qryInvoice WHERE DocketDate between #" & getStartDate() & "# and #" &
getEndDate() & "# AND CustomerID <> 6")
End If
While Not rs.EOF
rs.Edit
rs!Invoiced = True
rs.Update
rs.MoveNext
Wend
End If
End If

End Sub

Regards
Sandy
 
S

Sandy

I found a solution. I replaced the OpenRecordset code with DoCmd.RunSQL and
it works fine now.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top