Re: Loop through recordset of Crosstab query
- From: John von Colditz <johnvonc@xxxxxxxxxxxxx>
- Date: Wed, 23 Sep 2009 07:59:18 -0700
paul has brought this to us :
Hi
Im trying to loop through an Access crosstab query in a report in
Excel using the code below, however, whenever i get to the .movefirst
part i get the error:
"Operation is not supported for this type of object"
Any ideas how i can get around this?
Thanks for any suggestions.
Paul
Dim con As New ADODB.Connection
Dim rst As New ADODB.Recordset
con.Open _
"Provider=Microsoft.jet.oledb.4.0; Data Source=\
\feltapp0174\mapinfo_share\Pip\resources\pip.mdb"
rst.Open "qryLandSpendRPT", con, adOpenForwardOnly, adLockReadOnly
rownum = 5
With rst
.MoveFirst
If Not (.BOF And Not .EOF) Then
Do While Not rst.EOF
Worksheets("Summary").Cells(rownum, 1).Value = .Fields
("OpenYear")
Worksheets("Summary").Cells(rownum, 2).Value = .Fields
("Site_Name")
Worksheets("Summary").Cells(rownum, 3).Value = .Fields
("08/09")
Worksheets("Summary").Cells(rownum, 4).Value = .Fields
("09/10")
Worksheets("Summary").Cells(rownum, 5).Value = .Fields
("10/11")
Worksheets("Summary").Cells(rownum, 6).Value = .Fields
("11/12")
'Worksheets("Summary").Cells(rownum, 7).Value = .Fields
("12/13")
rownum = rownum + 1
.MoveNext
Loop
End If
End With
I suspect it is because you have a Forward Only cursor, and you are using a MoveFirst, which would be a move back. Comment out the ..MoveFirst, and I'll bet it works...
.
- Follow-Ups:
- Re: Loop through recordset of Crosstab query
- From: paul
- Re: Loop through recordset of Crosstab query
- References:
- Loop through recordset of Crosstab query
- From: paul
- Loop through recordset of Crosstab query
- Prev by Date: Loop through recordset of Crosstab query
- Next by Date: record when form last accessed
- Previous by thread: Loop through recordset of Crosstab query
- Next by thread: Re: Loop through recordset of Crosstab query
- Index(es):
Relevant Pages
|