chaseltine
February 2nd, 2000, 05:28 PM
Has anyone every tried to use the new VB 6.0 Data Report by binding it during run time to a data class that encapsulates several ADO objects? To make a long story short, we are unable to use the data environment to bind our data to the report, as the data is calculated during run time within the object, and is NOT saved to a database. But the client needs to be able to print a report containing this data, therefore, we must use our data classes, and the data they contain.
Whenever I bind during run time to my data class, I can print out data for any rpt control that exits in the Detail section, IF that is the only section that exists on the report. My problem occurs when I try to bind, unbind, and rebind the data report to print out data in rpt controls that exists in both the Group Header section, and the Detail section of the report. I have discovered that you MUST use seperate ADO objects for each section in the data report. But I still can't get the report to bind to more than one ado object during run time. The following is the code I am using. Note that my data class has a datasource behavior = vbDataSource, and a DataBindingBehavior = none.
Dim DataClass as new clsDataClass
Dim Dr as DataReport
'get the data and put it into two different ado object within the dataclass. Each ado object is assigned a DataMember name within the class
DataClass.GetGroupHeaderData
DataClass.GetDetailsData
If DataClass.RecordCount > 0 then
set Dr = drMyReport
'set report to first ado object
drMyReport.DataMember = "NameEmployer"
set drMyReport.DataSource = DataClass
With drMyReport.Sections("GroupHeader").Controls
for rptCtrl = 1 to .Count
If TypeOf .Item(i) is RptTextBox then
.Item(i).DataMember = "NameEmployer"
End If
next rptCtrl
End With
drMyReport.DataMember = ""
'set report to second ado object within the class
drMyReport.DataMember = "PaymentList"
set drMyReport.DataSource = DataClass
for i = 1 to DataClass.RecordCount
With drMyReport.Sections("Detail").Controls
for rptCtrl = 1 to .Count
If TypeOf .Item(rptCtrl) is RptTextBox then
.Item(rptCtrl).DataMember = "PaymentList"
End If
next rptCtrl
End With
next i
Anyone see what I am doing wrong here? Any advice would be greatly appreciated.
chaseltine
Whenever I bind during run time to my data class, I can print out data for any rpt control that exits in the Detail section, IF that is the only section that exists on the report. My problem occurs when I try to bind, unbind, and rebind the data report to print out data in rpt controls that exists in both the Group Header section, and the Detail section of the report. I have discovered that you MUST use seperate ADO objects for each section in the data report. But I still can't get the report to bind to more than one ado object during run time. The following is the code I am using. Note that my data class has a datasource behavior = vbDataSource, and a DataBindingBehavior = none.
Dim DataClass as new clsDataClass
Dim Dr as DataReport
'get the data and put it into two different ado object within the dataclass. Each ado object is assigned a DataMember name within the class
DataClass.GetGroupHeaderData
DataClass.GetDetailsData
If DataClass.RecordCount > 0 then
set Dr = drMyReport
'set report to first ado object
drMyReport.DataMember = "NameEmployer"
set drMyReport.DataSource = DataClass
With drMyReport.Sections("GroupHeader").Controls
for rptCtrl = 1 to .Count
If TypeOf .Item(i) is RptTextBox then
.Item(i).DataMember = "NameEmployer"
End If
next rptCtrl
End With
drMyReport.DataMember = ""
'set report to second ado object within the class
drMyReport.DataMember = "PaymentList"
set drMyReport.DataSource = DataClass
for i = 1 to DataClass.RecordCount
With drMyReport.Sections("Detail").Controls
for rptCtrl = 1 to .Count
If TypeOf .Item(rptCtrl) is RptTextBox then
.Item(rptCtrl).DataMember = "PaymentList"
End If
next rptCtrl
End With
next i
Anyone see what I am doing wrong here? Any advice would be greatly appreciated.
chaseltine