recordset problem?

krc777

Registered User.
Local time
Today, 06:25
Joined
Nov 29, 2005
Messages
70
I have the following code:

Dim rst As DAO.Recordset
Dim db As DAO.Database
Dim rst2 As DAO.Recordset

Set db = CurrentDb()
Set rst = db.OpenRecordset("MainRptDataASD Totals")

rst.MoveFirst
.
.
.
If myVal <> 0 And rst.Fields("PmtYr") < 2005 Then
'Find the next year matching ASD(myCat) and IPR(myIRP)
Set rst2 = db.OpenRecordset("SELECT " & monVal & " from MainRptDataASD where PlanName = '" & myplan & "' AND PmtYr = " & myYear + 1 & " AND ASD = '" & myCat & "' AND IPR = '" & myIPR & "'")
calcVal = (rst2.Fields(monVal) / myVal - 1)
rst.Edit
rst.Fields(totval) = calcVal
rst.Update
Else
rst.Edit
rst.Fields(totval) = 0
rst.Update
End If

When I reach the rst.edit lines I get the error message - database or object is read-only. This is not a read only db.
Any thoughts on how to correct this?
Thanks,
k
 
has the soucce table got a primary key ? if not i think it treats table as read only
 
Try the following and see what happens:
Set rst = db.OpenRecordset("[MainRptDataASD Totals]", dbOpenDynaset)
 

Users who are viewing this thread

Back
Top Bottom