Jamie Collins said:
No biggie: I wasn't using Access or ULS e.g. try this in Excel:
Sub test()
Dim cat
Set cat = CreateObject("ADOX.Catalog")
With cat
.Create _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\DropMe.mdb;"
Dim sSQL As String
sSQL = _
"CREATE PROCEDURE ProcTest AS " & _
"SELECT * FROM MSysObjects"
On Error Resume Next
.ActiveConnection.Execute sSQL
MsgBox Err.Description
On Error GoTo 0
End With
End Sub
It's something missing from the connection string. I tested your code
from Excel, and got the result you reported. I fiddled around to
simplify it, and got to the point where I'm running from within Access
against the same database I'm running in. (I have to close and reopen
the database after making code changes, so as not to have an exclusive
lock on the database.)
Working against the current database, I tried code like this:
'----- start of code -----
Dim conn
Set conn = CreateObject("ADODB.Connection")
conn.Open CurrentProject.Connection.ConnectionString
On Error Resume Next
conn.Execute _
"CREATE PROCEDURE ProcTestSys AS " & _
"SELECT * FROM MSysObjects"
Debug.Print Err.Number, Err.Description
conn.Close
'----- end of code -----
That code works fine, has no error, and creates the query.
If I change ...
conn.Open CurrentProject.Connection.ConnectionString
to ...
conn.Open _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & CurrentDb.Name & ";"
It does *not* work, and gives me the "no read permissions" error.
I suspect it has to do with being logged into the correct .mdw as a user
in the Admins group, but I haven't verified this. Note that this is a
database that has no user-level security applied, but all that really
means (in a practical sense) is that the default system.mdw is used and
the admin user has no password.