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 6770207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:17:05+00:00 2026-05-26T15:17:05+00:00

I have the following code: Dim cn As Object Dim rs As Object Dim

  • 0

I have the following code:

Dim cn As Object
Dim rs As Object
Dim strSql As String
Dim strConnection As String
Dim AppPath As String
Set cn = CreateObject("ADODB.Connection")
AppPath = Application.ActiveWorkbook.Path

Set rs = CreateObject("ADODB.RecordSet")

strConnection = "Provider=Microsoft.ACE.OLEDB.12.0;" & _
    "Data Source=" & AppPath & "\Masterlist_Current_copy.accdb;"

strSql = "SELECT [Neptune Number],[Description],[Manufacturer],[Manufacturer P/N] FROM [All Components];"
cn.Open strConnection
Set rs = cn.Execute(strSql)

'Need Code here to get Info out of recordset

I am trying to get information out of the recordset that has the query result being dumped into it. I’m trying to figure out how to query the recordset and get the number of rows with a specific value in the “Neptune Number” field. I will then insert the correct number of rows into the worksheet I’m modifying. After that I need to get the data for that value and insert it into the worksheet.

Note: I don’t care if recordset, datatable or anything else is used I simply need to be able to do what I described above. Please show code.

  • 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-26T15:17:05+00:00Added an answer on May 26, 2026 at 3:17 pm

    The easiest way to get where you I think you are asking to go is to modify your SQL statement changing

    strSql = "SELECT [Neptune Number],[Description],[Manufacturer],[Manufacturer P/N] FROM [All Components];"
    

    to

    strSql = "SELECT [Neptune Number],[Description],[Manufacturer],[Manufacturer P/N] FROM [All Components] WHERE [Neptune Number] = 'Specific Value' ;"
    

    This will force the sql query to only return the records you need. the .find method can be used for filtering the recordset, but i have avoided using it in this instance as it is cleaner to just ask the db for only the information that you want.

    to process the recordset you can use the following

    with rs
        'will skip further processing if no records returned
        if not (.bof and .eof) then
            'assuming you do not need the headers
            'loop through the recordset
            do while not .eof
                for i = 0 to .fields.count -1
                    'assuming the active sheet is where you want the data
                    cells(row, i + colOffset) = .fields(i).value
                next
                Rows(Row & ":" & Row).Insert
                .movenext
            loop
        end if
    end with
    

    Where row is the starting point of your data and colOffset is the starting column of your data. Note that this code does not do things in the exact order you specified in your question (I am inserting rows as needed instead of calcualting the number of records up front.)

    I have avoided using .recordcount because I find depending on the database used it will not return a correct record count.

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

Sidebar

Related Questions

I have following code in my application: // to set tip - photo in
I have the following code Case "Formula_MDX" Dim cubeid As String = Request("intCubeId") Dim
I have the following code to convert a distinguishedName to a sAMAccountName: Dim de
i have used following code to repeat a process creation/close iteratively dim vProcessInfo as
I have the following code: Private Sub SortWorksheet(ByVal sheet As Worksheet) Dim sStartColumn Dim
I have the following code in Visual Studio 2005. Dim OutFile As System.IO.StreamWriter Try
In VB6 code, I have the following: dim I as Long I = Weekday(Now,
I have following code in my Application. Comments in my code will specify My
I have following code in my application. [self.navigationController pushViewController:x animated:YES]; It will push a
I have following code in page load Protected Sub Page_Load(ByVal sender As Object, ByVal

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.