![]() |
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" _ ,) |
All times are GMT +1. The time now is 10:28 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com