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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

General ODBC Error

Status
Not open for further replies.

dionu

Programmer
Oct 19, 2001
10
CA
I am trying to add a querytable to an Excel form and I am receiving a general ODBC error at the .Refresh line of the following code... any ideas?

With Worksheets(1).QueryTables.Add(Connection:=strConn, Destination:=Range("A1"))
.Sql = strSQL
.Refresh
End With

I have checked the strConn and strSQL thoroughly.
 
Dionu,

I'm not one for doing those sorts of tasks by writing straight VBA... what you might try is to record a macro doing the action you would like Excel to replicate, and then clean up the result a bit and add in your variables for the connection and the SQL. Excel will probably add a lot of extraneous lines that you can judiciously remove, but you're sure to get the code right.

Good luck!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top