View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
urkec urkec is offline
external usenet poster
 
Posts: 131
Default ODBC excel Macro help needed

"Dan" wrote:

I understand. And I am no programmer. At least not in 20 years but that is
the only way it will work.

This is wierd though. I just took one of my working macros and deleted just
one of the CR LF (the one after the SELECT stmnt) in a statement and it
worked. Then I deleted the other two (after FROM and WHERE stmnts) and I get
this error "Run-time error '1004': SQL Syntax Error"

By the way if there is a better way to do ODBC queries in a macro let me
know. Like the connection statement. Can I connect once to the database and
then just call the tables that I need?

Back to my original problem: Could something have changed in Excel 2007? I
save my work and got on my onter computer running Excel 2003 and it worked.
I finished up the entire program and saved it. Pulled it up in Excel 2007
and I got the error. Strange.


What was the original error that made you insert Chr(13) & "" & Chr(10) & in
..CommandText? What did the Sql string look like before that?


Dan

"Bill Renaud" wrote in message
. ..
I have never seen Carriage Return and Line Feed embedded in the middle
of an SQL query before.


Neither have I. I made some test using Excel 2007, Sql Server 2000 and 2005,
with and without array function, using Chr(13) & "" & Chr(10) & or vbCrLf, or
just setting CommandText to a single line string, and it all worked.

Anybody else know if this is legal syntax?
(There may be something else wrong with your overall code; I just
happened to spot something that stood out.)
--
Regards,
Bill Renaud


--
urkec