Thread: Edit Query
View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
joel[_951_] joel[_951_] is offline
external usenet poster
 
Posts: 1
Default Edit Query


I copied this from the code you posted (recorded Macro). I just tried
similar code on one of my databases and got the same error. You somehow
got any extra comma in your recorded macro

from
..CommandText = Array(, SelectSQL & vbCrLf & _
FromSQL & vbCrLf & WhereSQL & vbCrLf & GroupbySQL)

to
..CommandText = Array(SelectSQL & vbCrLf & _
FromSQL & vbCrLf & WhereSQL & vbCrLf & GroupbySQL)

Here are some hints in writing a query
1) The query is simply a string. the command text portion of the string
is the SQL statements.
2) A SQL can be very long (I think 32,000 characters), but need to be
have a carriage return every 256 characters or less.
3) Make sure you have a delimiter (space, comma, return) between in part
of the SQL. for example

Don't do this
Select *From (I left out the space between the * and FROM).

4) The line continuation character (the underscore at the end of each
line) isn't seen by the SQL server. The SQL server see 2 lines in my
code as one long string. So don't leave out the Delimiters or returns
thinking the line continuation character is seperating the fileds of the
SQL.

5) Develope the SQL in small pieces to make it easier to to debug.


--
joel
------------------------------------------------------------------------
joel's Profile: http://www.thecodecage.com/forumz/member.php?u=229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=198559

http://www.thecodecage.com/forumz