Solved

cannot update field using recordsetclone

Posted on 2013-01-31
3
743 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 85
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 48

Accepted Solution

by:
Dale Fye 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

Enroll in July's Course of the Month

July's Course of the Month is now available! Enroll to learn HTML5 and prepare for certification. It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

630 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