Solved

cannot update field using recordsetclone

Posted on 2013-01-31
3
714 Views
Last Modified: 2013-02-01
I have a docmd.runsql statement that works(but has to do the whole set of records) so i have gone for a recordset clone approach as that seq field can be sequenced once the recordset has been filtered down.

however it says error 3027 database or object is read only. not sure why it works one way and not the other.

help would be appreciated.

Private Sub BtnAddSeqFields_Click()
Dim db As Database
Dim rst As Recordset


If MsgBox("processor heavy operation you may lose your mouse while running, you have option of filtering down and just resequence those records of interest proceed?", vbYesNo) = 6 Then
'DoCmd.RunSQL ("UPDATE TblExporthVinstems SET TblExporthVinstems.Seq = Right(OnlyAlphaNum([vin_original_dvla]),Val([Forms]![FrmExportVinCode].[LblExportSeqCount].[caption]));")
'

'alternative method to update seq field using only recordsetclone
Set rst = Me.RecordsetClone
With rst
.MoveFirst
Do While Not .EOF
.Edit (fails here)
!Seq = Right(OnlyAlphaNum([VIN_Original_DVLA]), Val([Forms]![FrmExportVinCode].[LblExportSeqCount].[Caption]))
.Update
.MoveNext
Loop
End With




Me.Requery

End If

End Sub

Open in new window

0
Comment
Question by:PeterBaileyUk
3 Comments
 
LVL 77

Expert Comment

by:peter57r
ID: 38842978
Can you update records through the form?

What is the recordsource for the form?

What filter have you applied and how did you do that?

Just to be safe, change :
Dim rst As Recordset
to
Dim rst As DAO.Recordset
0
 
LVL 84
ID: 38843139
I've never used the RecordsetClone to actually update data, only to move around in the records and have that reflected in the form. If you must update data, try either using the Recordset, of the form, or do it independently of the form and then requery/refresh the form.
0
 
LVL 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 500 total points
ID: 38843332
My guess is that the forms recordset is not directly updateable.  In the RunSQL statement you are updating a table, but in the recordsetclone you are updating the forms recordsource, which may be a read-only query.
0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question