Solved

Union View locking records

Posted on 2013-12-10
9
350 Views
Last Modified: 2013-12-10
Hi,

I have an Access front-end for a SQL server database.

In SQL Server I have created a view that is a union query on two of the tables.

The problem is that if a user is displaying the result of that union query, no-one can edit the data in the source tables.

Is that normal?

How can I present the data to one user, while allowing it to be edited by another?  In one form the users only need to see one record at a time (although it could be from either source table).  However there is another that displays all, so they can be filtered down to the ones that are of interest.

Cheers
0
Comment
Question by:LJKMartin
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 22

Expert Comment

by:Kelvin Sparks
ID: 39709517
A union query (view) is always non updateable.

You will need to develop an alternative for updating records.

Kelvin
0
 

Author Comment

by:LJKMartin
ID: 39709583
Hi Kelvin,

Yes, I know.  I'm not trying to update the union query.

If I open one of the tables directly, it won't let me change the data there while the union query is open in Access.
0
 
LVL 22

Expert Comment

by:Kelvin Sparks
ID: 39709673
Hmmmm,
is not behaviour I've experienced before. I don't have any suitable databases around at the moment to test.

Kelvin
0
 
LVL 40

Expert Comment

by:Vadim Rapp
ID: 39709703
I just tried it, and saw no problem. I.e. in Access I opened linked table that is linked to the UNION view on sql server, and while it was opened, I was able to edit the records in the underlying tables on sql server from another application.

How is the result of the union query displayed in Access? do you have linked table? query? form?
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 39709715
How are you using the Union query (view) in Access (as a continuous form, datasheet, in a combo or list)?

Have you linked to the view?

Are you creating a recordset from the view?

Can you use a disconnected recordset (http://support.microsoft.com/kb/184397) to perform whatever function you are trying to perform with the union query?
0
 
LVL 26

Accepted Solution

by:
Zberteoc earned 500 total points
ID: 39709781
In the view code use the (NOLOCK) hint in the FROM or JOIN clauses next to any table name you query:

SELECT
   ...
FROM
   table1 t1 (nolock)
  inner join table2 t2 (nolock)
  ...

UNION
SELECT
   ...
FROM
   table3 t3 (nolock)
  inner join table4 t4 (nolock)
  ...
0
 

Author Closing Comment

by:LJKMartin
ID: 39709865
Thank-you Zberteoc - a simple solution that works.
0
 
LVL 22

Expert Comment

by:Kelvin Sparks
ID: 39709936
Awesome - I learnt something new today!
0
 
LVL 40

Expert Comment

by:Vadim Rapp
ID: 39710024
I don't think it's very good solution, for the following two reasons.

1. This shouldn't be happening in the first place. Which means that something was wrong or misunderstood, and it's left that way. Usually when something is left misunderstood/unresolved, sooner or later it will come back.

2. If for whatever reason and in whatever way Access is placing the lock on the records, but in fact the lock is not in place due to (nolock) hint in sql server (of which Access is unaware), this may have unpredictable results in Access.

It would be better solution to find the exact reason in Access doing it, and eliminate it in Access. For instance, if the view is shown in Access form (the recommended way), or Query, check the form's/querie's property "record locks", and if it's set to "all records", change it accordingly.
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

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

13 Experts available now in Live!

Get 1:1 Help Now