LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default "acessor flags" creating pivot table from recordset

I'm using ADO to create a recordset which I'm trying to use to create a
pivot table. The code is below. I get error "One or more accessor flags
were invalid" on the CreatePivotTable line. I know the recordset has data.

TIA,

Wolfie

Dim rsData As ADODB.Recordset
Dim szConnect As String
Dim szSQL As String
Dim objPivotCache As PivotCache
Dim objPivotTable As PivotTable

' Create connection string
szConnect = "Provider=SQLOLEDB; Data Source=MyServer;;User ID=myuser; " & _
"password=mypassword"

' Create the SQL statement
szSQL = Worksheets("SQL_ActPlan").Range("A100").Value

' Create the Recordset object and run the query.
Set rsData = New ADODB.Recordset
rsData.Open szSQL, szConnect, adOpenForwardOnly, _
adLockReadOnly, adCmdText

' Make sure we got records back
If Not rsData.EOF Then
' Use the record set for the pivot table
Set objPivotCache = ActiveWorkbook.PivotCaches.Add(xlExternal)
Set objPivotCache.Recordset = rsData2
With objPivotCache
.CreatePivotTable TableDestination:="R7C1", _
TableName:="PivotTable1", ReadData:=True
End With
rsData2.Close
End If


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Create Pivot Table Data with Column "Sum" rather than "count" defa Johnny_99[_2_] Excel Discussion (Misc queries) 2 January 2nd 10 03:25 PM
Pivot Table Report Filter - "OR" instead of "AND" Multiple Filters tommcbrny Excel Discussion (Misc queries) 1 October 29th 09 03:08 AM
Pivot table "Group and Show Details" vs. "SubTotals" pgchop Excel Programming 0 February 1st 06 07:29 AM
Copy recordset from an Access "make table" query Laurie[_4_] Excel Programming 1 February 5th 04 09:45 AM
Creating small "recordset" or sorting a numeric 1-dim array Anthony Cravero Excel Programming 0 December 19th 03 06:36 PM


All times are GMT +1. The time now is 09:17 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"