VB.net Access Record(s) cannot be read. No read permission on "MySysObjects"

Posted on 2014-08-11
Medium Priority
Last Modified: 2014-09-08
Hi. I am using the following code to get a list of the Access queries in am Access database
but get the error:
Record(s) cannot be read. No read permission on "MySysObjects"

   Sub Populate_Combo_With_Access_Queries()

        'Dim oTable As New DataTable


            Dim sSQL As String = "SELECT [Name] FROM MSysObjects WHERE [Type] = 5"

            Dim connection As New OleDbConnection(Form_Settings.txtAccessConnectionString.Text)
            Dim cmd As New OleDbCommand(sSQL, connection)
            Dim datareader As OleDbDataReader = cmd.ExecuteReader
            While datareader.Read
                If Not datareader("Name").Equals(DBNull.Value) Then
                End If
            End While
        Catch ex As Exception
            MsgBox(ex.Message & " 67b")
        End Try

    End Sub
Question by:Murray Brown
  • 4
  • 2
  • 2
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 40254807
Then try copying the MSysObjects table in code, ...then rename it, ...then query the copy:

    DoCmd.CopyObject , "AccessObjects", acTable, "MSysObjects"

Then sSQL will be:
="SELECT [Name] FROM AccessObjects WHERE [Type] = 5"

LVL 74

Accepted Solution

Jeffrey Coachman earned 2000 total points
ID: 40254814
This is a bit more safe

'If AccessObjects does not exist, ...just continue and copy MSysObjects
On Error Resume Next
'Delete old AccessObjects
DoCmd.DeleteObject acTable, "AccessObjects"
'Copy MSysObjects as AccessObjects
DoCmd.CopyObject , "AccessObjects", acTable, "MSysObjects"
LVL 58
ID: 40255271

  This is .Net code...


   The DB your going against, is it a MDB file or a ACCDB?   If a MDB, do you know if the DB was secured?

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!


Author Comment

by:Murray Brown
ID: 40259957
Hi Jim. Thanks. It is a .accdb database

Author Comment

by:Murray Brown
ID: 40259994
If I reference the Microsoft Access 14.0 Object library it causes errors relating to Ribbon button control size so I don't want to connect to Access in this way. I am however connecting to Access using the following sort of code. So how would I get a list of Access Queries in this way?

     Dim connection As New OleDbConnection(cs
                Dim da As OleDbDataAdapter = New OleDbDataAdapter(sSQL, connection)
                da.Fill(oDataSet, "MyTableDT6")
                Me.DGV_Other.DataSource = oDataSet.Tables("MyTableDT6")
LVL 58
ID: 40260384
What does your connection string look like?
What format is the DB in? (MDB or ACCDB)?
Is this running in 32 or 64 bit?
Has the database been secured with a password?
Has the database been secured with ULS (User Level or Workgroup security).


Author Comment

by:Murray Brown
ID: 40272485
Connection String
Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\murbro\Dropbox\Online Excel\Malandela 11oes.accdb;
Database is .accdb
64 bit
No password
Not secured with ULS

Author Closing Comment

by:Murray Brown
ID: 40310702
Thanks. Sorry about late reply

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

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

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…
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses
Course of the Month16 days, 22 hours left to enroll

864 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