Solved

How to change RunPermissions via code

Posted on 2006-10-26
10
306 Views
Last Modified: 2012-06-27
How do I change the RunPermissions of all exiting and new queries in the current database to 'Owner' using VBA code?
0
Comment
Question by:Milewskp
  • 5
  • 4
10 Comments
 
LVL 6

Expert Comment

by:yhwhlivesinme
ID: 17814903
In your query design you should just put the statement:

With Owneraccess

that will make the query run with the owner's access rights
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 17814933

Application.SetOption ("Run Permissions"), 0     'owner

Application.SetOption ("Run Permissions"), 1     'user
0
 
LVL 1

Author Comment

by:Milewskp
ID: 17815439
Thanks cap, that explains how to set the run permissions for new queries, but is there a way to set the run permissions of the existing queries (other than setting the SQL string for each qeury)?
0
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 17815471
you have to modify the Sql of the queryDef

do you need the codes?
0
 
LVL 1

Author Comment

by:Milewskp
ID: 17815674
please
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 17815730
do you want to delete or add  WITH OWNERACCESS OPTION
0
 
LVL 1

Author Comment

by:Milewskp
ID: 17815743
add
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 17815790


Function AlterQDef(strPerm As String)
Dim qd As QueryDef, sSql As String
For Each qd In CurrentDb.QueryDefs
    If InStr(qd.Name, "~") = 0 Then
        If InStr(qd.sql, strPerm) = 0 Then
            sSql = Replace(qd.sql, ";", "")
            sSql = sSql & " " & strPerm
            qd.sql = sSql
        End If
    End If
Next
End Function

to use
AlterQDef("WITH OWNERACCESS OPTION")



0
 
LVL 1

Author Comment

by:Milewskp
ID: 17815856
Thanks cap!
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 17815869
U R Welcome!!!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
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…

679 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