Access- how to change a group of queries
Can anyone show me the code needed to loop through all of the queries in a database and change the RunPermissions property to the "Owner's" value?
This is Access97, by the way.
Thanks!
Web Development
Can anyone show me the code needed to loop through all of the queries in a database and change the RunPermissions property to the "Owner's" value?
This is Access97, by the way.
Thanks!
by esadacca
This will get you the list of queries... I've haven't yet found the property for "RunPermissions"
Public Sub ListQueries()
Dim db As Database, qdf As QueryDef
Set db = CurrentDb
For Each qdf In db.QueryDefs Debug.Print qdf.Name
Next qdf
Set db = Nothing
End Sub
by esadacca
Here's a "hack":
Public Sub UpdateQueries()
Dim db As Database, qdf As QueryDef, strSQL As String
Set db = CurrentDb
For Each qdf In db.QueryDefs
strSQL = Trim(UCase(qdf.SQL))
If InStr(1, strSQL, "WITH OWNERACCESSOPTION") = 0 Then
'remove the trailing semicolon
strSQL = Left(strSQL, InStr(1, strSQL, ";") - 1)
'append the "owneraccess" sql
strSQL = strSQL & " WITH OWNERACCESS OPTION;"
End If
qdf.SQL = strSQL
Next qdf
Set db = Nothing
End Sub
This discussion is closed to new replies.
Sort by Trending