Article ID: 131331
Article Last Modified on 8/15/2005
SELECT orders.EMPLOY_ID, orders.ORDER_AMT
FROM c:\windows\msapps\msquery\orders.dbf orders
WHERE (orders.ORDER_DATE>={d '1989-06-01'})
Sub GetSourceData()
Dim SQLString As Variant
Dim RowCount As Integer
Dim SQLRange As Range
Set SQLRange = Range("Sheet1!A1")
' Assign the SourceData array to the SQLString variable.
SQLString = SQLRange.PivotTable.SourceData
' Loop through each element of the SQLString array and copy these
' elements to Sheet1, starting in cell A1 and going down.
RowCount = 0
For Each xElement In SQLString
' The first element is the Connection String.
' Each additional element is the SELECT Statement
' broken in to 200-character text strings.
Range("A1").Offset(RowCount, 0).Value = xElement
RowCount = RowCount + 1
Next
End Sub
Note that if the first element, which is the Connection String, is greater
than 255 characters, it will be truncated. However, each additional element
makes up the SELECT statement and these elements are broken into strings of
200 characters each.
SourceData
Additional query words: XL5 XL7 XL97 XL98 5.00a 5.00c 7.00a XL
Keywords: kbhowto kbualink97 kbprogramming kbdtacode KB131331