PDA

Click to See Complete Forum and Search --> : Data Reports - 2 Data Sources?


hyme
Aug 29th, 2000, 10:20 AM
Howdy!

Is it possible to have 2 data sources on a Data Report?
The reason I am asking is because I need to put 2 seperate tables in the same detail section.

Example:

Dim cn As New ADODB.Connection
Dim rs,rs2 As New ADODB.Recordset
Dim cmd,cmd2 As New ADODB.Command

cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Test.mdb;"

With cmd
.ActiveConnection = cn
.CommandType = adCmdText
.CommandText = "Select * from tbl1 order by tbl1.Index"
.Execute
End With

With cmd2
.ActiveConnection = cn
.CommandType = adCmdText
.CommandText = "Select * from tbl2 order by Index"
.Execute
End With

With rs
.ActiveConnection = cn
.CursorLocation = adUseClient
.Open cmd
End With

With rs2
.ActiveConnection = cn
.CursorLocation = adUseClient
.Open cmd2
End With

Dim q As Integer
Dim intCtrl As Integer
Dim X As Integer
Dim z As Integer

X = 0
q = 1
z = 1

With DR
Set .DataSource = rs
.DataMember = ""

With .Sections("Section1").Controls
For intCtrl = 1 To .Count
If TypeOf .Item(intCtrl) Is RptTextBox Then
.Item(intCtrl).DataMember = ""
.Item(intCtrl).DataField = rs(z).Name
End If
Next intCtrl
End With
End With

With DR
Set .DataSource = rs2
.DataMember = ""
With .Sections("Section1").Controls
For intCtrl = 3 To .Count
If TypeOf .Item(intCtrl) Is RptTextBox Then
.Item(intCtrl).DataMember = ""
.Item(intCtrl).DataField = rs2(q).Name
q = q + 1
End If
Next intCtrl

End With
End With

If I set the dr.Datasource to rs2, it loses connection with rs. If anyone has any suggestions, it would be great!

Thanx


DR.Refresh
DR.Show