Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 23rd, 2003, 11:59 AM
leatham leatham is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 1 leatham User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Exclamation SQL Excel probs

Anyone any ideas why this code keeps on popping up with "incomplete datasource". I have used this sql statement in microsoft query without any problems and I am sure it is not the databases problem. could it be the way i have had to go onto a new line in the middle of the statement?

Thanks


Sub Macro2()
'
' Macro2 Macro
' Macro recorded 23/12/2003 by Freddie Leatham
'

'
With ActiveSheet.QueryTables.Add(Connection:=Array(Array( _
"ODBC;DSN=BOCOMIS02;Description=OMIS;SERVER=GBLOND003s32;UID=Radar_Admi n;PWD=Radar_Admin;APP=Microsoft® Query;WSID=GBLOND027092;Netwo" _
), Array("rk=DBMSSOCN;Address=GBLOND003s32,2025")), Destination:=Range("A2"))
Dim strSQL As String

strSQL = "SELECT Location.Name, products.product_name, kri_reporting_periods.reporting_period_name, SUM(vwHeadcount.Headcount), FROM Location, [Location World], products, [products ProductGroup], kri_reporting_periods, kri_reporting_types, vwHeadcount, [Location Region], [Location Country] WHERE ( ProductGroup.product_id=products.product_parent_id ) AND ( World.Id=Region.ContainingLocationId ) AND ( Region.Id=Country.ContainingLocationId ) AND ( Country.Id=Location.ContainingLocationId ) AND ( kri_reporting_periods.reporting_period_id=vwHeadcount.reporting_period_id ) AND ( Location.Id=vwHeadcount.LocationId ) AND ( products.product_id=vwHeadcount.ProductTypeId ) AND ( kri_reporting_periods.reporting_type_id=kri_reporting_types.reporting_type_id ) AND ( World.ContainingLocationId = 0 ) AND ( ProductGroup.product_parent_id =0 ) AND ( kri_reporting_types.reporting_type_name = 'Month' ) AND ( Location.Name = 'Singapore (CPT)' AND (World.ContainingLocationId = 0 ))" _
& "GROUP BY Location.Name, products.product_name, kri_reporting_periods.reporting_period_name """

.FieldNames = True
.RefreshStyle = xlInsertDeleteCells
.RowNumbers = False
.FillAdjacentFormulas = False
.RefreshOnFileOpen = False
.HasAutoFormat = True
.BackgroundQuery = True
.TablesOnlyFromHTML = True
.Refresh BackgroundQuery:=False
.SavePassword = True
.SaveData = True
End With
End Sub

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > SQL Excel probs


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT