Solved

Can`t Update query using recordset in vba access

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Access query with left expression 5 29
MS Access Tables Linking 6 40
Search Form not Querying 2 10
Running Total in Access 4 0
When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

910 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