Excel adodb Operation must use an updateable query

drag1c

Board Regular
Joined
Aug 7, 2019
Messages
97
Office Version
  1. 2016
  2. 2013
Platform
  1. Windows
Hi,

I've encoutered really strange error in both microsoft access query design and in excel vba adodb.

Updateable query looks like this:
Code:
strSQL = "UPDATE tbWorkplanPNs " & _
                        "SET tbWorkplanPNs.Version = ( " & _
                        "SELECT TOP 1 tbWorkplanRevision.Version " & _
                        "FROM tbWorkplanRevision " & _
                        "WHERE tbWorkplanRevision.Workplan = tbWorkplanPNs.Workplan " & _
                        "ORDER BY tbWorkplanRevision.[Current Date] DESC " & _
                        ") WHERE tbWorkplanPNs.Workplan = '" & .myvalue.Value & "'"

            conn.Execute strSQL

For some strange reason, error is "Operation must use an updateable query."

I've tested this query in Microsoft Access and I can view it in "Datasheet view" but when I try to run it from Access Objects, it gives the same error.
My Assumption is that Access have issues when using parameters like TOP 1 and DESC, so it might require Temporary table with sorted data.

Could anyone provide answer? If that's so, could anyone create that kind of query or fix this one, so in future I can look for a way to do it myself :(
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Your assumption is incorrect. A subquery is not updatable so you will have to devise a workaround - perhaps a staging table or update a recordset, or a function that retrieves the sub value(s). Perhaps the tables are not correctly related, given that you need the subquery. Can you not just join them and use the TOP predicate (and perhaps criteria as well)?
 
Upvote 0
Your assumption is incorrect. A subquery is not updatable so you will have to devise a workaround - perhaps a staging table or update a recordset, or a function that retrieves the sub value(s). Perhaps the tables are not correctly related, given that you need the subquery. Can you not just join them and use the TOP predicate (and perhaps criteria as well)?
Well, to make it work, I need to use DESC and TOP 1, because of the latest date.
I will see some workaround with temporary tables which I will drop at end.

Thank you sir.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,176
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top