Open rst for update (1 Viewer)

LNewton

Registered User.
Local time
Today, 16:08
Joined
Jan 24, 2002
Messages
31
When the database calls this function it returns the runt-time error 3027 Can't update database or object is read only. I am opening the recordset with the Set rstOrders = dbs.OpenRecordset("qryRoundConfirmedORDERS")but when it moves to the rstOrders.Edit it errors? Where should I look next to debug?

Function RoundConfirmedOrders()
Dim dbs As Database, rstOrders As Recordset

Set dbs = CurrentDb
Set rstOrders = dbs.OpenRecordset("qryRoundConfirmedORDERS")

rstOrders.MoveFirst

Do Until rstOrders.EOF
rstOrders.Edit
If rstOrders!ORD_CERT = "D" Then
If Not IsNull(rstOrders!INV_SDEC) Then
rstOrders!ORD_CUTS = Round(rstOrders!ORD_CUTS, rstOrders!INV_SDEC)
Else
rstOrders!ORD_CUTS = Round(rstOrders!ORD_CUTS, 3)
End If
End If
If rstOrders!ORD_CERT = "U" Then
rstOrders!ORD_CCSH = Round(rstOrders!ORD_CCSH, 2)
End If
rstOrders.Update
rstOrders.MoveNext
Loop
rstOrders.Close
RoundConfirmedOrders = True
End Function
 

SteveA

Registered User.
Local time
Tomorrow, 01:08
Joined
Oct 8, 2001
Messages
126
Have you checked to see if the query is actually returning an updateable recordset. Try running the query by itself and see if you can make changes, and add or delete entries.

If the query allows you to do this, try the following line:

Code:
Set rstOrders = dbs.OpenRecordset("qryRoundConfirmedORDERS",dbOpenDynaset)

dbOpenDynaset returns a recordset that can be fully maintained (to the best of my knowledge). The one downfall is that it does use a bit more memory as the recordset is indexed etc to allow searching, bookmarking etc. I haven't noticed any significant delays but it is just something to be mindful of.

HTH
SteveA
 

Users who are viewing this thread

Top Bottom