#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA and SQL

I have a worksheet that I want to query using SQL. I do not want to
filter the data. This is what I have done so far and I get an error.
I have a class modlue "rpt" with dataws defined as a specific sheet in
my workbook, wb is the activeworkbook, rptDatabase is the named range
I want to query. my conncection string is set up as follows. Do I
need to add a reference to make this work and if so which one? I
appreciate any help you might have.

Public Property Get ConnString() As String
ConnString = "Driver={Microsoft Excel Driver (*.xls)};" _
& "DriverId=790;" _
& "Dbq= " & wb.Path & "\" & wb.Name & ";" _
& "DefaultDir=" & wb.Path & "\" & wb.Name
End Property



Dim mySQL As String
Dim qt As QueryTable
mySQL = "Select Market, Specialty FROM [rptDatabase] WHERE
Market='Ped'"
Set qt = rpt.dataws.QueryTables.Add(rpt.ConnString,
rpt.dataws.Cells(1, 43), mySQL)
qt.Refresh

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 09:59 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"