Solved

Can`t Update query using recordset in vba access

Posted on 2014-09-03
4
296 Views
Last Modified: 2015-01-01
Can`t Update query in recordset :
I have this lines of code:

Dim rs As DAO.Recordset
Dim rsFiltered As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("qAddCheckBoxsForBankMimsarimAndBrinksPlusOneD", dbOpenDynaset)

rs.Filter = "TaarichPlus2 = T_Pizoor"
Set rsFiltered = rs.OpenRecordset

If Not (rsFiltered.BOF And rsFiltered.EOF) Then
rsFiltered.MoveFirst
Do Until rsFiltered.EOF
rsFiltered.Edit
rsFiltered!BrinksBankMimsarimID = GetNewID("tblBrinksFiles")
rsFiltered("BrinksBankMizomanID") = GetNewID("tblBrinksFiles")
rsFiltered.Update
rsFiltered.MoveNext
Loop
End If
rs.Close
rsFiltered.Close

I got error: Cannot update.database or object is read-only (error 3027)

 in this line :
rsFiltered.Edit
0
Comment
Question by:drtopserv
  • 2
4 Comments
 

Author Comment

by:drtopserv
ID: 40300390
the content of the query  is :

SELECT tblBrinksFiles.BrinksBankMimsarimID, tblBankMimsarim.BankMimsarimID, tblBrinksFiles.Snif_Sholiach, tblBrinksFiles.ErichMovalBrinksMimsarimMatched, tblBankMimsarim.ErichMovalBankMimsarimMatched, tblBrinksFiles.Erich_Moval, tblBrinksFiles.T_Pizoor, Format([T_Pizoor],"ddd") AS sT_Pizoor, tblBankMimsarim.Taarich, IIf(Format([Taarich],"ddd")<>"ה",[Taarich]+1,[Taarich]+3) AS TaarichPlus2, Format([Taarich],"ddd") AS sTaarich, tblBankMimsarim.Sug_Tchola, tblBrinksFiles.ErichMovalBrinksMimsarimMatchedUpdateTypeStatus, tblBankMimsarim.ErichMovalBankMimsarimMatchedUpdateTypeStatus, tblBrinksFiles.T_Esoof, Format([T_Esoof],"ddd") AS sT_Esoof, tblBrinksFiles.AutomationCheckNoteBrinksMimsarim, tblBankMimsarim.AutomationCheckNoteBankMimsarim
FROM tblBrinksFiles INNER JOIN tblBankMimsarim ON (tblBrinksFiles.Snif_Sholiach = tblBankMimsarim.Snif_Sholiach) AND (tblBrinksFiles.Sug_Tchola = tblBankMimsarim.Sug_Tchola) AND (tblBrinksFiles.Erich_Moval = tblBankMimsarim.Erich_Moval_Shalim);
0
 
LVL 11

Expert Comment

by:Dany Balian
ID: 40300416
try this:
Set rs = CurrentDb.OpenRecordset("qAddCheckBoxsForBankMimsarimAndBrinksPlusOneD",dbOpenDynamic,0,dbOptimistic)

Open in new window


source: Microsoft: Run-Time Error '3027' Using ODBCDirect to Open RecordSet
0
 

Author Comment

by:drtopserv
ID: 40300443
invalid argument error 3001
0
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 total points
ID: 40300664
Is the query itself updateable? That is, if you open the query in Design View in Access, can you then modify the query?

If it is updateable, then you might try removing the rst.Filter, and instead just create a recordset with a filter:

Set rs = CurrentDb.OpenRecordset("SELECT * FROM qAddCheckBoxsForBankMimsarimAndBrinksPlusOneD WHERE TaarichPlus2 = T_Pizoor", dbOpenDynaset)

Although it looks like the WHERE clause above (and your Filter line) are wrong. If you want to filter on a VALUE name "T_Pizoor", then you'd have to somehow supply that value. Is "T_Pizoor" a value from a form? Doesn't look like it, but if you could explain more about that it would be helpful.


See this blog post for a listing of reasons that can cause a query to be not updatedable:

http://rogersaccessblog.blogspot.com/2009/11/this-recordset-is-not-updateable-why.html
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

706 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

18 Experts available now in Live!

Get 1:1 Help Now