Solved

Can`t Update query using recordset in vba access

Posted on 2014-09-03
4
314 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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Suggested Solutions

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
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…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

803 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