Database or Object is Read-Only

justice8965

Registered User.
Local time
Today, 06:40
Joined
Aug 25, 2009
Messages
32
Hey guys. I'm getting this error message when trying to delete something from a recordset based on a query. Basically if there is a negative number in the recordset, its purpose is to cancel out a positive number of the same value. So what I'd like to do is delete all negative rows and the corresponding positive rows, then do my calculations. Heres my code.

'Set parameters for query
Set qd = dbs.QueryDefs("qry12month")
For Each prm In qd.Parameters
prm.Value = Eval(prm.Name)
Next prm

Set rs = qd.OpenRecordset




'Remove negatives before calculating
For x = 0 To (rs.RecordCount - 1)

rowDelete = False

If rs(0) < 0 Then

negUse = rs(0)
rs.delete
rs.MoveFirst

For y = 0 To (rs.RecordCount - 1)
If rs(0) = (negUse * (-1)) Then
rs.delete
rowDelete = True
Else
rs.Move (1)
End If
Next

Else
rs.Move (1)
End If

If rowDelete = True Then
rs.MoveFirst
End If

Next



The error occurs at the rs.delete. Any ideas?
 
What is the SQL for qry12month? It has to be updateable for it to be able to delete from it. So, open that query directly and see if you can delete something from it. If not, see here.
 

Users who are viewing this thread

Back
Top Bottom