Solved

cannot update field using recordsetclone

Posted on 2013-01-31
3
727 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Familiarize people with the process of utilizing SQL Server stored procedures 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 Micr…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

734 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