Solved

I need to iterate through a RecordSet in VBA and display that data

Posted on 2011-09-08
2
320 Views
Last Modified: 2012-05-12
The following line is executing with no errors, which make me pretty sure Myrecordset has valid data in it, that I can extract and display:

Myrecordset.Open MyCommand, , adOpenDynamic, adLockReadOnly


I would like to find out how to:

1) Extract the data
2) Display that data in Excel 2007

Thanks.
0
Comment
Question by:newbieweb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 34

Accepted Solution

by:
Norie earned 500 total points
ID: 36503838
Like I said in the other question, use CopyFromRecordset.
Worksheets("Sheet1").Range("A1").CopyFromRecordset Myrecordset

Open in new window

This will put the data in Sheet1 starting at A1, it won't have headers though.

If you want headers, this will add the fields names in row 1 and the data in row 2 down.
Set rng = Worksheets("Sheet1").Range("A1")
For Each fld In Myrecordset.Fields

        rng.Value = fld.Name
        Set rng = rng.Offset(,1)
Next fld

Worksheets("Sheet1").Range("A2").CopyFromRecordset Myrecordset

Open in new window

0
 

Author Closing Comment

by:newbieweb
ID: 36504081
Thanks a million!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

738 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