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
Solved

How do I make a query in Access to be not-updateable

Posted on 2010-11-30
14
512 Views
Last Modified: 2012-05-10
I want my queries to NOT be updateable.  Is there a way I can force that?  Thanks.
0
Comment
Question by:DDSchreck
14 Comments
 
LVL 24

Expert Comment

by:fridom
ID: 34246160
In Access 2003 one can use workgroup files, with the proper permissions you can deny the modifying of queries. However you have to see that QueryDef will not work properly also.

The alternative is explained in the Access Cookbook 1.16 "save my Queries in a table for better programmatic access and security.

Regards
Friedrich
0
 
LVL 12

Expert Comment

by:pastorchris
ID: 34246561
0
 

Author Comment

by:DDSchreck
ID: 34249742
Let me clarify the scenario - I was too vague.

I have a new access user who is going to be working in my database.  When he makes a query, I do not want the recordset to be updateable.  I don't want him to accidentally change the data in the recordset returned by the query.  I know if the queries are complex enough, the recordset is not updateable.  Is there something he can do to assure any query he makes produces a non-updateable recordset?
0
Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

 
LVL 45

Accepted Solution

by:
aikimark earned 500 total points
ID: 34251006

1

Right-click on the top half of the query wizard window

2

Select properties

3

You can set the Read-Only property or you can change the recordset type to Snapshot (which can not be updated).
0
 
LVL 75
ID: 34251151
"When he makes a query, I do not want the recordset to be updateable."
The Key word here is  "He' ... when 'He' makes the query.  aikimark has specified the way to do this; however, that is not going to be bullet proof by any stretch, since anyone opening the query in design view can change that.

So, a more realistic way is to 1) not allow directly 'viewing' (or editing) data view a 'live' query. Instead, you need to create a UI (forms, etc) to work with the data.  This way, based on who the Windows user is, you can set a Form's Allow Edits property to Yes/No accordingly.

mx
0
 
LVL 45

Expert Comment

by:aikimark
ID: 34251358
thanks for the points.

to expand on DatabaseMX comment.  You would probably be better off by having a test environment with copies of the production tables.  It wouldn't matter if the mysterious 'HE' wrote and executed an update query, since it wouldn't touch the production data.

=======
Another way to do this is to create your own front-end query wizard that is only capable of creating a SELECT query.

=======
Another way to do this is to have an invisible form with a timer event that kicks off every minute (or few seconds) and looks at the saved queries for any UPDATE, INSERT, DELETE, or MakeTable queries.  The timer event code could hide or delete the querydef.
 
0
 
LVL 75
ID: 34251425
"Another way to do this is to create your own front-end query wizard that is only capable of creating a SELECT query."
How would that prevent this ?

Another way to deal with this is ... A Form that you select a query form say a List box, then use this code to open the query in Read Only mode:

DoCmd.OpenQuery "TheSelectedQueryName", ,acViewNormal,acReadOnly

mx
0
 
LVL 45

Expert Comment

by:aikimark
ID: 34251478
>>How would that prevent this ?

If this is a user, it might mean that the user has a limited number of application forms for doing their work.  The other windows might be hidden from the user, including the database window.  If the user didn't have access to the MS-Access query wizard, they would be able to create queries using this query-wizard substitute.
0
 
LVL 45

Expert Comment

by:aikimark
ID: 34251497
One of my applications allows users to create their own SELECT queries.  The users can name these queries for later use.  The user can see all the queries that they created as well as 'system' queries that I created.
0
 
LVL 75
ID: 34251508
But a stock SELECT query is updatable, unless you set the Recordset Type to Snapshot like you suggested ....

mx
0
 
LVL 45

Expert Comment

by:aikimark
ID: 34251908
ah.  The queries can only be used in a read-only setting.  The user does not get to see the query results directly.

If I needed to create a querydef from these, I could programmatically make them read-only via property setting.  I could also include a read-only table.  My favorite trick here is to have a one-row table and add a read-only query of the table, setting the query's RecordsetType property = 2 (snapshot).  Then, I can easily add the read only query in the user-defined query's FROM clause to make it read-only.
0
 
LVL 75
ID: 34251953
" I could also include a read-only table."
In Access?  How do you do that ?

"The user does not get to see the query results directly."
aka via a form then ?

mx
0
 
LVL 45

Expert Comment

by:aikimark
ID: 34252047
>>" I could also include a read-only table."

Typo.  Should read "I could also include a read-only query."

Good catch, mx.  Thanks.

=======
>>aka via a form then
They do see the results in a form, but in a non-updateable control (multi-column Listbox).  They can also run a report that is based on their row-selection criterion.
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

User Beware!  This is a rather permanent solution to removing your email from an exchange server.  The only way to truly go back is to have your exchange administrator restore your mailbox from backups.  This is usually the option of last resort.  A…
Article by: Leon
Software Metering within our group of companies has always been an afterthought until auditing of software and licensing became a pain point. Orchestrator and SCCM metering gave us the answer and it was an exciting process.
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…
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…

856 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