Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Type Mismatch error with QueryTable's sql property

Status
Not open for further replies.

foxbldr

Programmer
Apr 16, 2002
109
0
0
CA
Hi All,

I am running a VBA module that uses QueryTable object to populate a worksheet. I am getting an error with following line although my sql string looks ok.

Code:
With activesheet.QueryTable(....)
  .Sql= Array(strSqlStatement)
...

end with

strSqlStatement =" select ..,...,...,... from tbl1, tbl2,tbl3, tbl4 where <join conditions>"

Sometimes it works when I remove where clause but even it wasn't consistent. I am accessing Visual Foxpro Tables using DSN.

I am using MS Excel 97 and it uses Ms Query 8.00e .

Any help is much appreciated.

Foxbldr












 
Code:
With activesheet.QueryTable(....)
  .Sql= strSqlStatement
...

end with

No need for the Array qualifier when using a straight SQL statement.

I hope this helps.

Ron Repp

If gray hair is a sign of wisdom, then I'm a genius.
 
RonRepp,

Yes, you are right! Usage of Array was giving me troubles.

Thanks -Foxbldr
 
The array is only there in the recorded version to control the number of characters......

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top