Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Importing Query Results into Arrays

Status
Not open for further replies.

Kingstonian

Programmer
May 27, 2002
3
0
0
GB
I am hoping to import the data from Report Tabs in a Business Objects Document, but I can never seem to work out how to trap the data results either in a variable or an array.

Does anybody have any ideas?

 
Don't worry all. Fixed it myself:

Dim boapp As busobj.Application
Dim MyDoc As busobj.Document
Dim bodps As busobj.DataProviders
Dim bodp As busobj.DataProvider
Dim bocols As busobj.Columns
Dim theColumn As busobj.Column
Dim i As Long
Dim c As Long
Dim ColCount As Long
Dim RowCount As Long
Dim DataArray1() As Variant

Public Sub InsertData()
Set MyDoc = ActiveDocument
Set bodps = MyDoc.DataProviders
Set bodp = bodps.Item(1)
Set bocols = bodp.Columns
' Count columns and rows
ColCount = bocols.Count
For i = 1 To ColCount
If RowCount < bocols.Item(i).Count Then
RowCount = bocols.Item(i).Count
End If
Next
'
ReDim DataArray1(1 To RowCount, 1 To ColCount) As Variant
For i = 1 To ColCount
Set theColumn = bocols.Item(i)
For c = 1 To theColumn.Count
DataArray1(c, i) = theColumn.Item(c)
Next c
Next i
End Sub

I would like to point out that if you replace the array with cell refs in Excel or Recordsets in Access, you can populate them directly from the Data Provider without having to ExportAsText, etc. Just a thought. Ta Da.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top