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

x
?
Solved

Can`t Update query using recordset in vba access

Posted on 2014-09-03
4
Medium Priority
?
409 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
[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
  • 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 85

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 1500 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

721 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