Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

cannot update field using recordsetclone

Posted on 2013-01-31
3
Medium Priority
?
753 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 2000 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

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

688 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