LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4
Default syntax error in VBA in query from Access

I have a query in Excel 2003 to run a query to Access database. If I manually
run the query it works, but my macro to run it bombs out with Compile Error-
Syntax Error.
It is a complicated query linking several tables, but why would it work to
run manual and not work in VBA?
Here it is in case anyone wants to slug thur it- more after, but it stops
where the double break appears below

With Selection.QueryTable
.Connection = Array(Array( _
"ODBC;DSN=CustomDietResearch;Description=Custo m Diet Research
Database;UID=CustomDietResearch;APP=Microsoft Office 2003;WSID=378PC11;" _
),
Array("DATABASE=Teklad_Custom_Diet_Research;Truste d_Connection=Yes"))
.CommandText = Array( _


"SELECT Diet.TDNumber, Diet.DietName, Diet.UserID,
CustomerInformation.CompanyName, CustomerInformation.ContactName,
CustomerInformation.PhoneNumber, CustomerInformation.EmailAddress,
DietIndexingInfor" _
, _
"mation.Species, DietIndexingInformation.ModificationDiet,
DietIndexingInformation.KeyFeature2, DietIndexingInformation.KeyFeature3,
DietIndexingInformation.KeyFeature4, DietCustomerServiceInfo.Special" _
, _
"Packaging, DietCustomerServiceInfo.FormDescription,
DietCustomerServiceInfo.Irradiated,
DietCustomerServiceInfo.CustomerInfo"&chr(13)&""&c hr(10)&"FROM
Teklad_Custom_Diet_Research.CustomDietResearch.Cus tomerInformation Cu" _
, _
"stomerInformation,
Teklad_Custom_Diet_Research.CustomDietResearch.Die t Diet,
Teklad_Custom_Diet_Research.CustomDietResearch.Die tCustomerServiceInfo
DietCustomerServiceInfo, Teklad_Custom_Diet_Research" _
, _
".CustomDietResearch.DietIndexingInformation
DietIndexingInformation"&chr(13)&""&chr(10)&"WHERE
CustomerInformation.TDNumber = Diet.TDNumber AND Diet.TDNumber =
DietCustomerServiceInfo.TDNumber AND DietCustomerServiceInfo" _
,)

 
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
Excel 2007 MS Query prompt yields Syntax error Bruce Excel Discussion (Misc queries) 0 May 26th 06 11:06 AM
MS Query import from Excel - Syntax Error EstherJ Excel Discussion (Misc queries) 1 April 24th 06 09:44 AM
Syntax Error in Excel Query for DATE field James T Excel Discussion (Misc queries) 3 August 31st 05 12:33 PM
Syntax Error - Using Microsoft Query and ODBC link to a table James T Excel Discussion (Misc queries) 0 August 31st 05 02:18 AM
Syntax error (missing operator) in query expression '6 Wescott Rd# shealy Excel Discussion (Misc queries) 0 June 9th 05 09:53 PM


All times are GMT +1. The time now is 08:52 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"