Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default Command text syntax and comma

I recorded the following macro for to import data from SQL.

At line 5 why is there ", " in the syntax i.e. {ts '2004-02-18 00:00:", "00'} ?
I want to reduce this to {ts '2004-02-18 00:00:00'} but I get type mismatch

What is the ", " there for and why cant I get rid of it. I want to replace the hard coded date with a variable.

Dave

.CommandText = Array( _
"SELECT qry_ASX_52Weeks.WeekEnding, qry_ASX_52Weeks.ASXCode, qry_ASX_52Weeks.AveWeeklyClose" & Chr(13) & "" & Chr(10) & _
"FROM qry_ASX_52Weeks qry_ASX_52Weeks" & Chr(13) & "" & Chr(10) & _
"WHERE (qry_ASX_52Weeks.WeekEnding<={ts '2004-02-18 00:00:", "00'} And qry_ASX_52Weeks.WeekEnding={ts '" _
& Start & _
"'}) AND (qry_ASX_52Weeks.ASXCode='" & compname & "')" & Chr(13) & "" & Chr(10) & _
"ORDER BY qry_ASX_52Weeks.WeekEnding")




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Command text syntax and comma

I saw the response to this not too long ago, as I am currently as wel
experimenting with the Querytables.add

now I am not sure for the exact reason, something to do with the lengt
of strings, but the Commandtext string has been chopped in to smalle
sections and assembled in an array.


Code
-------------------

.CommandText = Array( _
"This is a very very lon" _
,"g string and thats wh" _
,"y it was cut in so man" _
,"y differnt array segme" _
,"nts so that it will work")

-------------------

so if you just move the ", " part a little bit back in your code, i
should be easier to insert your formula

--
Message posted from http://www.ExcelForum.com

Reply
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
using a conditional suffix in text function format syntax=text(value,format_text) Brotherharry Excel Worksheet Functions 1 January 13th 09 03:03 PM
Extract the text between last comma and last but one comma. Sreedevi Excel Worksheet Functions 2 March 5th 08 11:12 PM
Pivot Table Error Message - "Command Text not set for command obje Jeff Divian Excel Discussion (Misc queries) 0 November 7th 07 10:26 PM
syntax for "IF" commend to check for multiple empty cells bf comma Chris Excel Worksheet Functions 4 September 3rd 07 12:02 PM
Correct syntax for use Replace command via DDE? Bjørn Holm Excel Programming 4 November 27th 03 01:07 PM


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