Hello, I keep getting subscript out of range error when connection to the database and I can't figure out why, there is already an existing connection with the table. Any help would be highly appreciated, thank you!
Code:
With ActiveWorkbook.Connections("mnlsapp02 SLP B10Data") _
.OLEDBConnection
.BackgroundQuery = True
.CommandText = Array( _
"SELECT * FROM dbo.B10Data WHERE SalesPeriod = '" & Period & "'")
.CommandType = xlCmdSql
.Connection = Array( _
"OLEDB;Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=True;Data Source=mnlsapp02;Use Procedure for Prepare=1;Auto T" _
, _
"ranslate=True;Packet Size=4096;Workstation ID=MNLW692;Use Encryption for Data=False;Tag with column collation when possible=Fals" _
, "e;Initial Catalog=SLP")
.RefreshOnFileOpen = False
.SavePassword = False
.SourceConnectionFile = ""
.SourceDataFile = ""
.ServerCredentialsMethod = xlCredentialsMethodIntegrated
.AlwaysUseConnectionFile = False
'.ServerFillColor = False
'.ServerFontStyle = False
'.ServerNumberFormat = False
'.ServerTextColor = False
End With