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

  • Home
  • SEARCH
  • 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 6007931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:45:10+00:00 2026-05-23T01:45:10+00:00

I’m trying to take an ADO Recordset and then loop through it to parse

  • 0

I’m trying to take an ADO Recordset and then loop through it to parse individual rows to different worksheets within an Excel workbook. Unfortunately, as I step through my code, I get the following error: Run-time error ’13’: Type mismatch. This occurs when I call the sub in my code – it never actually steps into the sub. I’m wondering if I’m somehow not passing the Recordset in correctly or if it’s a problem somewhere within my loop.

Regardless, here’s my code – any help is greatly appreciated!

Sub SplitData(ByVal rs As ADODB.Recordset)

' Instantiate count variables for each result type
' Start at 2 to give room for Table headers on sheets
Dim NewAppsCount, BadLogCount, MatNotesCount, ZeroBalCount As Integer
NewAppsCount , BadLogCount, MatNotesCount, ZeroBalCount = 2

' Row Counter
Dim Count As Long
Count = 0

' Loop through the recordset and parse rows to appropriate worksheets
Do While Not rs.EOF
    If CStr(rs.Fields("Maturity Date")) = "" Then
        If CStr(rs.Fields("Log_Date")) = "" Then
            ' Applications that have not been properly logged
            Sheet4.Range("A" & CStr(BadLogCount)) = rs.Fields(Count).Value
            Count = Count + 1
            BadLogCount = BadLogCount + 1
        Else
            ' New Applications
            Sheet6.Range("A" & CStr(NewAppsCount)) = rs.Fields(Count).Value
            Count = Count + 1
            NewAppsCount = NewAppsCount + 1
        End If
    Else
        If Month(rs.Fields("Maturity Date")) < Month(Date) Then
            ' Maturing Notes with Zero Outstanding Balance
            Sheet7.Range("A" & CStr(ZeroBalCount)) = rs.Fields(Count).Value
            Count = Count + 1
            ZeroBalCount = ZeroBalCount + 1
        Else
            ' Maturing Notes
            Sheet8.Range("A" & CStr(MatNotesCount)) = rs.Fields(Count).Value
            Count = Count + 1
            MatNotesCount = MatNotesCount + 1
        End If
    End If
    rs.MoveNext
Loop

End Sub

Here is the sub that call GetData:

Sub GetData(ByVal Update As Boolean)
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim query As String
Dim path As String
Dim prompt, result As Integer
Dim day, today As String

' ...skipping stuff not related to the issue...

    ' Set the UNC Path
    path = "\\this\is\the\path"

    ' Instantiate ADO Objects
    Set conn = New ADODB.Connection
    Set rs = New ADODB.Recordset

    ' Connect to data source
    conn.Open "Provider=Microsost.JET.OLEDB.4.0;Data Source=" & path & ";"

    ' The Query
    query = "This is a big 'ol query that I won't repost here"

    'Run the query and populate the Recordset object
    rs.CursorLocation = adUseClient
    rs.Open query, conn, adOpenStatic, adLockReadOnly

    'Parse contetns of Recordset to worksheet
    Application.ScreenUpdating = False
    Me.SplitData(rs)

    'Close the ADO Objects, set them to null, and exit sub
    rs.Close
    conn.Close
    Set rs = Nothing
    Set conn = Nothing
    Exit Sub
End Sub
  • 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-05-23T01:45:11+00:00Added an answer on May 23, 2026 at 1:45 am

    Try changing:

    Me.SplitData(rs)
    

    to:

    Me.SplitData rs
    

    Unnecessary parentheses often cause problems in VBA.

    (NB I’m assuming that the two Sub shown are in a context where Me makes sense – e.g. class module, ThisWorkbook module, worksheet module, backing a UserForm etc)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

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.