Solved

cannot update field using recordsetclone

Posted on 2013-01-31
3
675 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Familiarize people with the process of utilizing SQL Server views 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 Access…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

708 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now