Excel 2003, Access 2003.
From Excel VBA, I am refreshing a querytable with output from an SQL statement via an ODBC DSN connection as follows:
I have left out the sql statement for brevity, however, the query is failing on refresh. I copied the sql to Access and it is always failing on the 1024 character. VBA seems to be placing some character in the string at 1024 characters that Access can't handle. I can fix the query in Access by pressing delete after the 1,023 character. I have rejigged the query by moving field names around but the query always fails at the same number of characters i.e 1024.
The code worked under 2000 for both Access and Excel, but has failed since moving to 2003 for both.
Any help appreciated.
The risk with keeping an open mind is having your brains fall out.
Shaunk
From Excel VBA, I am refreshing a querytable with output from an SQL statement via an ODBC DSN connection as follows:
Code:
Const Connstring = "ODBC;DSN=Client_Adjunct"
With ActiveSheet.QueryTables.Add(Connection:=Connstring, Destination:=Range("A1"), Sql:=Sql_Client_Adjunct)
.RefreshStyle = xlInsertDeleteCells
.Name = Client_Audit
.FieldNames = True
.Refresh BackgroundQuery = True
End With
I have left out the sql statement for brevity, however, the query is failing on refresh. I copied the sql to Access and it is always failing on the 1024 character. VBA seems to be placing some character in the string at 1024 characters that Access can't handle. I can fix the query in Access by pressing delete after the 1,023 character. I have rejigged the query by moving field names around but the query always fails at the same number of characters i.e 1024.
The code worked under 2000 for both Access and Excel, but has failed since moving to 2003 for both.
Any help appreciated.
The risk with keeping an open mind is having your brains fall out.
Shaunk