Solved

Union View locking records

Posted on 2013-12-10
9
377 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
[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
  • 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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
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
 
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 27

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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

739 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