Solved

VBA Query won't Edit

Posted on 2016-08-31
8
44 Views
Last Modified: 2016-09-07
Can someone point out why this code crashes at the .Edit saying  that the database or query is read-only?

The code is set in an Access 2010 front-end linked to a SQL Server database.

The Access file is not read only - lots of similar procedures run OK.

The dataset the query produces is updateable - i can open it manually and change the DistributeOrderCard field.



Sub TestCust()
Dim db As Database
Dim recust As Recordset

Set db = CurrentDb()

'open customers
    Set recCust = db.OpenRecordset("qry101DistNewOrderCards", dbOpenDynaset, dbSeeChanges)
'test
    recCust.Edit
    recCust![DistributeOrderCard] = False
    recCust.Update
End Sub
0
Comment
Question by:LJKMartin
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 25

Expert Comment

by:SStory
ID: 41778170
I'm thinking about the tables or views that you are accessing on the SQL Server side. Do you have permissions to do more than just read?

Also certain types of queries are always read only. Then there is Access Secuirty permissions and SQL Server Security perms
0
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 41778186
also, see if your query "qry101DistNewOrderCards" falls in the items listed from this link
When can I update data from a query?
0
 

Author Comment

by:LJKMartin
ID: 41778328
Ah yes, the query is Dynaset (inconsistent updates).  Is there a way of making it updateable via VBA.
0
 
LVL 25

Expert Comment

by:SStory
ID: 41778465
LJKMartin: First make sure permissions are set to allow it in SQL Server and in Access.  Is this VBA inside of Access itself?
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 34

Expert Comment

by:PatHartman
ID: 41780579
Open the query in datasheet view.  Can you update rows?  If you can't then you can't use the query in VBA as an editable recordsource.

What is making the query not updateable?
0
 

Author Comment

by:LJKMartin
ID: 41783553
Yes, I can open the query in datasheet view and edit, but only because it's Dynaset (inconsistent updates).

The option in VBA is dbOpenDynaset, so I guess that's not allowing inconsistent updates.  Is there an option that allows inconsistent updates?

The query selects from another that has outer joins - which makes it not updateable.

I'm not sure what permissions I need to check, but there are dozens of other queries that work fine, so I'll be surprised if it's that.
0
 
LVL 34

Accepted Solution

by:
PatHartman earned 500 total points
ID: 41786593
Help for Access has gotten progressively worse since its peak with A97 but strangely enough, Help actually gives you this answer.

https://msdn.microsoft.com/en-us/library/office/ff820966.aspx
0
 

Author Closing Comment

by:LJKMartin
ID: 41787685
Thanks Pat,

Who'd have thought that Help would actually have the answer!
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

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Familiarize people with the process of utilizing SQL Server functions 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 Microsoft Ac…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

920 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

14 Experts available now in Live!

Get 1:1 Help Now