Type Mismatch when running query on SQL Database

G

Guest

Hi,

I'm trying to run a query from Excel against an SQL Database. I get a Type
Mismatch error when it is executing the following line of code.

Sheets(SQLDestinationSheet).Range(SQLDestinationCell).QueryTable.CommandText
= Array(FullSQL)

Now this works fine for the rest of the program except for my last query and
I suspect it is because the SQL statement that I store in the variable
FullSQL is greater than 255 characters long.

Anybody come across this and know a way around it?

Ta.
 
K

keepITcool

have you tried splitting that string?
this is an ultra crude way of doing it...
Replace/Split need xl2k+

dim vaSql, sFullSQL$
if len(sFullSQL) <= 255 then
vaSQL = array(sFullSQL)
else
sFullSql = replace(sfullSql," ",chr$(22))
vaSql = split(sfullsql,chr$(22))
end if

... .QueryTable.commandtext = vaSql




--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Neily wrote :
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top