KG Old Wolf
Board Regular
- Joined
- Sep 20, 2009
- Messages
- 65
All,
I need a fresh set of eyes... I just can't see the issue with the first "with" line of code (connection string). I am attempting to write my first "parameter-driven" query in VBA. Thanks for any suggestions....
I need a fresh set of eyes... I just can't see the issue with the first "with" line of code (connection string). I am attempting to write my first "parameter-driven" query in VBA. Thanks for any suggestions....
Rich (BB code):
Sub qry_Divsions()
'
'
' Parameter driven query to extract specific client Division locations
'
Dim qry_Practice_Abbr As String
qry_Practice_Abbr = Range("prm_Practice_Abbr")
'
'
With ActiveSheet.Query.Tables.Add(Connection:=Array( _
"ODBC;DSN=CMS2;Description=CMS2; _
APP=Microsoft Office 2010;DATABASE=cms_data; _
Trusted_Connection=Yes), Destination:=Range("$A$1"))
'
.CommandText = Array( _
"SELECT Division.DivisionAbbr, Division.FeeSchedUpdate, Division.projDate, Practice.PracticeAbbr, Practice.PracticeName, Practice.FiscalYearEnd" & Chr(13) & "" & Chr(10) & "FROM cms_data.dbo.Division Division, cms_data.dbo.Practi" _
, "ce Practice" & Chr(13) & "" & Chr(10) & "WHERE Division.PracticeID = qry_Practice_Abbr")
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = False
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.ListObject.DisplayName = "Table_Query_from_CMS2"
.Refresh BackgroundQuery:=False
'
End With
'
'
End Sub
Last edited by a moderator: