CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Query Count ADO

  1. #1
    Join Date
    Mar 2002
    Location
    Colorado
    Posts
    105

    Query Count ADO

    Hi all,

    I want to pull data from a query in my MS access database into a a cell on an Excel spread sheet. The query that I use has one field and has the Total property set to the "Count" type.

    The following is my connection to the .mdb file... from Excel. I have the name of the count field set, exactly as its generated by MS Access. I get the error: "Runtime Error - 3265"

    "The Item cannot be found in the collection corresponding to the requested name or ordinal ."

    Code:
    Option Explicit
    
    Const dbFullName As String = "C:\Documents and Settings\Larry.Bargers\Desktop\CompTesting.mdb"
    
    
    Private Sub Worksheet_Activate()
          
        Dim cn As ADODB.Connection
        Dim rs As ADODB.Recordset
        
        Set cn = New ADODB.Connection
        cn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & dbFullName & ";" & _
        "Jet OLEDB:Database Password=RCAT;"
           
        Set rs = New ADODB.Recordset
        
        rs.Open "qryUniqueOpenIssues", cn, adOpenDynamic, adLockOptimistic, adCmdTable
    
        rs.MoveFirst
        
        Me.Cells(3, 4) = rs![countOfTest/Advisory] 'I get the error when this line is read in...
        
        rs.Close
        
    End Sub
    Thanks for any help..
    Larry

  2. #2
    Join Date
    Dec 2004
    Posts
    423

    Re: Query Count ADO

    I think you have change your source:
    Code:
       rs.open "SELECT * FROM qryUniqueOpenIssues", cn....
    Even if everybody spoke the same language, nobody would be speaking the same language.

    --Daniel

  3. #3
    Join Date
    Mar 2002
    Location
    Colorado
    Posts
    105

    Re: Query Count ADO

    Your right Sabin.. the query was incorrect... Thanks..

    Larry

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured