Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8511449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:59:42+00:00 2026-06-11T03:59:42+00:00

I have a perplexing problem that I have been grappling with for many hours

  • 0

I have a perplexing problem that I have been grappling with for many hours to no avail.

Our (general audience) application compares queries in the latest version of our MS-Access database with end-users currently installed versions and and updates/syncs. the DB accordingly. Although this functionality has been working, it is now broken. I have resorted to the simplest test to demonstrate the behavior. OLEDB is NOT returning the correct number of queries.

After opening the Access 2007 database, I display the location and correct number of queries:

?CurrentDB.Name
C:\Users\Ron\Documents\Database4.accdb
?CurrentDB.QueryDefs.Count
1 

The following simple form calls the OleDbSchemaTable method, but returns the wrong number of rows / queries (=0):

Public Class Form1
    Private ConnStr As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Ron\Documents\Database4.accdb"

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Dim dbo As DataTable = GetSchemaInfo()
        Debug.Print("Number of queries=" & dbo.Rows.Count)
    End Sub
    Private Function GetSchemaInfo()
        Try
            Dim db As DataTable
            Using conn = New OleDb.OleDbConnection(ConnStr)
                conn.Open()
                db = conn.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Procedures, Nothing)
            End Using
            Return db

        Catch ex As Exception
            MsgBox(ex.Message)
            Return Nothing
        End Try
    End Function
End Class

Immediate Window:
Number of queries=0

I have tried everything I can think of (Compact/Repair, running on a different machine). Unfortunately, I have only one copy of Access 2007 to test with. Could this be a virus?

Any and all ideas are appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T03:59:44+00:00Added an answer on June 11, 2026 at 3:59 am

    There are 2 types of saved queries.

    1. Simple SELECT queries which could be created with CREATE VIEW DDL statements.
    2. All other queries. These can not be created with CREATE VIEW but could be with CREATE PROCEDURE. Included within this category are: “action queries” (insert, update, delete, “make table”); parameter queries; simple SELECT queries which include an ORDER BY clause; and perhaps more I can’t recall at the moment.

    Schema views include the first type. Schema procedures include the second type. QueryDefs.Count gives you the count of all saved queries, which includes both types.

    Try the VBA procedure below in your database. With my database, I get this output in the Immediate window:

    QueryDefs.Count: 66
    Views: 34
    Procedures: 32
    

    Unfortunately I don’t know how to translate this VBA to Dot.Net. Perhaps that doesn’t matter. I just want to emphasize that QueryDefs.Count should be the count of views plus the count of procedures. And it looks to me like your code asks for procedures only.

    Public Sub CountQueries()
        Const adSchemaProcedures = 16
        Const adSchemaViews = 23
        Dim cn As Object
        Dim rs As Object
        Dim i As Long
    
        Debug.Print "QueryDefs.Count: " & CurrentDb.QueryDefs.Count
    
        Set cn = CurrentProject.Connection
        Set rs = cn.OpenSchema(adSchemaViews)
        i = 0
        With rs
            Do While Not .EOF
                i = i + 1
                'Debug.Print !TABLE_NAME '
                .MoveNext
            Loop
            .Close
        End With
        Debug.Print "Views: " & CStr(i)
    
        Set rs = cn.OpenSchema(adSchemaProcedures)
        i = 0
        With rs
            Do While Not .EOF
                i = i + 1
                'Debug.Print !PROCEDURE_NAME '
                .MoveNext
            Loop
            .Close
        End With
        Debug.Print "Procedures: " & CStr(i)
    
        Set rs = Nothing
        Set cn = Nothing
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem that is and has been perplexing me for hours. I
I have been dabbling a little with clisp. It is a little perplexing that
I've got a problem thats been perplexing me for a while. I have a
I have another pretty perplexing problem that one of you might be able to
I have a very perplexing problem. A site I'm developing looks fine on iPad,
I have a perplexing issue that I can't seem to comprehend... I have two
I have a perplexing SQL select statement (ugly) that I'm trying to write in
I have a rather confusing problem in running our game. I am trying to
I'm writing a Java application that will have an on-screen number pad available for
I have a simple, but perplexing problem, with Math. The following code will take

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.