• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 553
  • Last Modified:

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

I want my queries to NOT be updateable.  Is there a way I can force that?  Thanks.
0
DDSchreck
Asked:
DDSchreck
1 Solution
 
fridomCommented:
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
 
Chris MConsulting - Technology ServicesCommented:
0
 
DDSchreckAuthor Commented:
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
aikimarkCommented:

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
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
"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
 
aikimarkCommented:
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
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
"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
 
aikimarkCommented:
>>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
 
aikimarkCommented:
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
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
But a stock SELECT query is updatable, unless you set the Recordset Type to Snapshot like you suggested ....

mx
0
 
aikimarkCommented:
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
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
" 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
 
aikimarkCommented:
>>" 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

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now