?
Solved

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

Posted on 2011-09-08
2
Medium Priority
?
331 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
2 Comments
 
LVL 35

Accepted Solution

by:
Norie earned 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Cancel future meetings from user mailboxes in Office 365 using Remove-CalendarEvents
New style of hardware planning for Microsoft Exchange server.
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.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

862 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