Solved

How to change RunPermissions via code

Posted on 2006-10-26
10
300 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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 
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

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.

Question has a verified solution.

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

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
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…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

831 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