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: 4
Default [Microsoft][ODBC Driver Manager] error

Would anyone advice on why I am getting this error? Excel VBA code to extract
data from Access (see picture).

Thanks in advance.

Sub CreatePivotTableFromDB()
Dim PTCache As PivotCache
Dim PT As PivotTable
Dim DBFile As Variant

On Error Resume Next
Application.DisplayAlerts = False
Sheets("PivotSheet").Delete
On Error GoTo 0

'Create a Pivot Cache
Set PTCache = ActiveWorkbook.PivotCaches.Add(SourceType:=xlExter nal)

'Connect to database and do query
DBFile = ThisWorkbook.Path & "\budget.mdb"
ConString = "ODBC;DSN=MS Acess Database;DBQ=" & DBFile

QueryString = "SELECT * FROM BUDGET"
With PTCache
.Connection = ConString
.CommandText = QueryString
End With

'add new worksheet
Worksheets.Add
ActiveSheet.Name = "PivotSheet"

'create pivot table<===========Error at the line below
Set PT =
PTCache.CreatePivotTable(TableDestination:=Sheets( "PivotSheet").Range("A1"),
TableName:="BudgetPivot")

'add fields
With PT
.PivotFields("DEPARTMENT").Orientation = xlRowField
.PivotFields("MONTH").Orientation = xlColumnField
.PivotFields("DIVISION").Orientation = xlPageField
.PivotFields("BUDGET").Orientation = xlDataField
.PivotFields("ACTUAL").Orientation = xlDataField
End With
End Sub


 
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
ODBC Driver Manager: Option type out of range TerryM Excel Discussion (Misc queries) 4 April 13th 10 05:33 PM
I try to download a spreadsheet and get a odbc driver manager err Steve Setting up and Configuration of Excel 0 July 27th 07 08:48 PM
Microsoft][ODBC SQL Server Driver]Syntax error or access violation Jordan Excel Discussion (Misc queries) 0 July 6th 05 06:58 PM
Error processing the dimension '[Microsoft][ODBC dBase Driver] To. Catalin Excel Discussion (Misc queries) 0 April 22nd 05 05:48 PM
Microsoft][ODBC Excel Driver]General error Unable to open registry key 'Temporary (volatile) Jet DSN rsbitian Excel Programming 0 October 22nd 03 06:11 AM


All times are GMT +1. The time now is 02:42 PM.

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"