|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > SQL Excel probs |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|